Was working then suddenly: QtGui/QApplication: No such file or directory. Why are the include files unavailable ?



  • I have a largish project which was compiling well. Suddenly for no apparent reason QtCreator is complaining at:
    @#include <QtGui/QApplication> @

    I cannot see that I have changed anything significant. I feel that the installation of Qt has broken in some way. I found a mention of this problem on the net saying that clearing .qmake.cache solved the problem, but I cannot find this file.

    Any ideas ? What does it need to find this header ?

    I am using:
    Qt Creator 3.0.0
    Based on Qt 5.2.0 (GCC 4.6.1, 64 bit)



  • I am now sure that this is a bug in QtCreator. If I start a new project and copy in all the source/headers/forms of the failing project everything compiles well UNTIL I make an edit to LIBS and INCLUDEPATH. Then the system says it cannot find QtGui/QApplication. Undoing the edit to the LIBS and INCLUDEPATH does not cause the system to work again. It is now a dead project until it is completely created from scratch again. Some persistent data must get corrupted, but what ?



  • I have solved the problem. Looks like the code is wrong, but it is compiling until I force a clean or rebuild - then the error occurs. Any edit to the .pro file causes the rebuild it would appear. Please don't waste any time on this - like I have :)


  • Lifetime Qt Champion

    Hi,

    If for example your are doing
    @
    LIBS = -L/usr/lib/my_lib_path
    @

    or

    @
    INCLUDEPATH = /usr/include/my_include_path
    @

    You are in fact clearing these variables, you need to use e.g.

    @
    LIBS += -L/usr/lib/my_lib_path
    @

    Hope it helps


  • Moderators

    Hi,

    I'm surprised that it compiles in the first place.

    <QtGui/QApplication> exists in Qt 4, but has been changed to <QtWidgets/QApplication> in Qt 5. The previous header no longer works.

    The recommended approach is to do this, which will work on both Qt 4 and Qt 5:
    @
    #include <QApplication>
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.