Important: Please read the Qt Code of Conduct -

What Environmental Variables PATH I need to add for Qt5 to recognize include <QtGui/QApplication> [Solved]

  • What Environmental Variables PATH I need to add for Qt5 to recognize include <QtGui/QApplication> ?
    I already added "C:\qt5\2012.11\qtbase\bin and C:\qt5\2012.11\qtbase\lib"

  • Moderators

    Includes are not handled by PATH. There is no <QtGui/QApplication> in Qt5. It's either <QtWidgets/QApplication> or <QtGui/QGuiApplication>, depending on what you need.

  • It's sounds odd to me, they changed the includes! meaning Qt5 not supported by older projects without changing all the includes? Now I need to manually change all my projects includes?

  • Moderators

    "All" is a bit of an exaggeration here... it's just QApplication and a few others (Qt has over 1000 classes... most of them were not changed). You can always stop using module names in front of the includes - this way source compatibility is preserved (so, you can use just <QApplication>).

    I have ported a few projects to Qt5 and I have to tell you - this is really not a problem. First, you do it once only, second - you can use automated tools provided in Qt5 to do it with a single click, third - there aren't really that many differences.

    Going back to QApplication - the reason behind those changes is that the Gui module was split. Now the stack is: QtCore, QtGui + either QtWidgets or QtQuick. Some general classes were left in QtGui, while all the widget-specific ones were moved to QtWidgets.

  • The problem I have some shared projects with a friend and he is using Qt 4.8.x.
    We using Dropbox and we are working on the same projects at the same time (which works pretty well, with the file refreshment dialog), now if I work with Qt5 we can't do it, as the file includes will be different...

  • Moderators

    You can, just use a few macros.

    #if QT_VERSION_MAJOR >= 0x050000
    #include <QtGui/QGuiApplication>
    #include <QtGui/QApplication>

    Or, as hinted before, just go with:
    #include <QApplication>

    You can take a look at Qt Creator sources, they are using this very same trick.

  • Ok I'll give it a try, thanks!
    By the way there is any diffrences between those two git packs: and, as they both seems to be Qt5 projects?

  • Moderators

    I don't know. I use the qt5 one to checkout and compile qt5 sources. SDK probably also provides the installer.

    Actual code is stored in module branches anyway (qt/qtbase, qt/qtxml etc.).

  • OK thanks, final question what configure did you use?

  • Moderators

    I usually follow "the instructions on the wiki": But you can also download the Qt5 Beta 2 SDK, it was released yesterday.

Log in to reply