Very belatedly, I have decided to migrate my project EP Simulator from Trolltech’s gui framework Qt version 3 to version 4. I should have started with Qt4 in the first place, but all my books were Qt3 books (actually I own just 1 Qt book), and I had the mistaken notion that Qt4 wouldn’t work on my computer until KDE 4 was released. For the non-Linuxy folks reading, KDE is a desktop manager for Linux, and the current version 3 is based on the Qt3. The new, yet-to-be-released version is based on Qt4. I initially didn’t release that both Qts could cohabitate on the same computer, which is silly. Anyway, once started with Qt3, I hesitated to switch because of the large numbers of incompatibilities between the 2 versions. Oh, back to you non-Linux users, I better explain that Qt is a gui framework that you can use to add gui elements such as menus, toolbars, dialog boxes, etc, etc to your programs. It is extremely elegant, in my opinion, but there is the little matter that it has a dual license. If you use it to develop proprietary programs not released under an open source license, you have to pay literally thousands of dollars for the privilege. Using it to develop open-source programs however is free, as in beer.
Why upgrade now? Qt3 will not be supported forever. Qt4 is better than Qt3, in many ways beyond the scope of this short blog entry. Qt4 really allows cross-platform development, as there is a Windows version of Qt4 for open-source development (there really wasn’t one for Qt3). The downside of upgrading is that Qt3 is not very compatible with Qt4. Classes, constructors, functions, etc. have changed. Forms designed with Qt Designer have changed, and the way these forms are subclassed is different. Trolltech, the makers of Qt provide instructions on their website to help with transition, but it is not easy. They provide a tool, qt3to4, to convert source files, and a compatibility library to support old Qt3 classes. But I am finding out a lot of the work has to be done by hand.
To start out, I copied my local unmirrored repository using svk (svk is great for this kind of thing) and created a qt4 branch. Even prior to that I first checked to make sure everything compiled under Qt3, without warnings or errors. With my local branch I can play around, checking in and updating to my local repository without ever affecting the mirrored repository or the central repository on sourceforge.net. Eventually when all the changes are made, I’ll smerge back to the local trunk and then push the changes back to the central repository. Again, svk makes this real easy.
I followed the instructions on the Trolltech website: http://doc.trolltech.com/4.2/porting4.html running the qt3to4 tool. This went smoothly. I installed the Qt4 packages (including development and debug packages) using the Smart package manager. I changed the project settings to use Qt4 instead of Qt3, and made sure the paths were correct. I compiled, and of course, there were 10 million errors.
The next step was to convert my ui (user interface) files. More on this next time.