Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Porting C++ Applications to Qt 5

This topic talks about the Qt Widgets changes in Qt 5. The following step-by-step instructions take you through the changes required to port the Animated Tiles application to Qt 5:

  1. Open the Animated Tiles project using Qt Creator.
  2. Edit main.cpp and replace the #include <QtGui> instance with #include <QtWidgets>. The Perl-script fixqt4headers.pl can be used to scan the source files of a project and perform the replacements.
  3. Edit the animatedtiles.pro and add QT += widgets towards the end of the file.

    Note: Qt GUI is included by default in all Qt applications unless excluded using the QT -= gui directive in the qmake project file.

  4. Save the changes and run the application.

Once you see the application running, check whether it behaves as expected.

"A snapshot of the \c animatedtiles application running on Ubuntu v12.04"

It is also possible to keep the project compiling with Qt 4 and Qt 5. This requires:

  1. Omitting the module name from all includes by running the fixqt4headers.pl script with the --strip-modules option.
  2. Adding scopes depending on the version of Qt to the .pro files:
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
  3. Introducing #if scopes around code using modified API:
    #if QT_VERSION >= 0x050000

if you are using Qt WebKit, see Qt WebKit to Qt WebEngine porting instructions.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded