Porting Cute Chess to Qt 6
I spent the end of March and the beginning of April porting Cute Chess to Qt 6.
Cute Chess supports Qt 5.11 to 5.15 and, now, the latest available Qt 6 version. Qt 5.11 is packaged in the latest Debian stable (Buster) and we want people to be able to compile Cute Chess with minimal amount of additional work. After the next Debian stable release, we’ll bump the minimum required version to 5.12 since it’s the Qt version that comes with the latest Ubuntu LTS release (20.04) . The plan is to support either Debian stable or the latest Ubuntu LTS — whichever is the oldest.
This is the second major Qt version jump for Cute Chess. In 2015, when Qt 4 was approaching its end-of-life, we started the port to Qt 5. Port to Qt 6 turned out to require more work compared to the jump from Qt 4 to Qt 5. We had been depending on the Qt 5 backwards compatibility and the code base included uses of deprecated modules that had not been cleaned during previous transition.
As with the previous major Qt version jump, the provided Qt porting documentation was excellent. There’s the general porting guide and module specific documentation. In our case the changes to Qt Core and Qt GUI were most relevant.
My approach to the porting work was similar to my writing: get a working prototype out as soon as possible. My plan was not to implement complete Qt 6 support but the required changes to get Cute Chess working as it did on previous Qt versions. I opted to use the core5compat compatibility module so that the APIs removed in Qt 6 would still be available. This did not fix the cases where individual methods were removed from existing classes, but made the porting effort easier.
The biggest hurdle with the porting effort was the backward compatibility with
Qt 5.11. Many compatibility features with Qt 6 were added in Qt 5.14 and Qt
5.15 which were not available (for example Qt::endl and
Qt::SkipEmptyParts). I wanted to avoid the uses of version
dependent #ifdefs
where possible but unfortunately they were required in
many changesets.
QCustomPlot, the largest third-party dependency of Cute Chess, created its own extra “spice” for Qt 6 compatibility. When I started the porting work, QCustomPlot didn’t support Qt 6 and its Gitlab repository had gone quiet. People were wondering whether the project has been abandoned and started to create their own forks. I, too, forked the project and worked to add Qt 6 compatibility but discarded it when an updated version of QCustomPlot was released on 29th of March with full Qt 6 support.
After two rounds of review, I merged Qt 6 compatibility to Cute Chess on 14th April.