Important: Please read the Qt Code of Conduct -

Qt Creator - QApplication: No such file or directory

  • Hi,

    I successfully configured Qt Creator for cross-compilation and remote debugging. I'm using Qt 4.8.3.

    Everything works perfectly except in the code editor the #include <QApplication> (and all Qt headers) is underlined and I get no assistance when writing code.

    In what directories is the Qt Creator looking for the headers?

    Note: I have a device specific qmake.conf, that uses an environmental variable that contains a sysroot path to configure include and lib paths. For compilation I set the variable in Build Environment in Projects settings.

  • Hi,
    In your .pro add following lines.

    QT       += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    In your main.cpp replace #include <QApplication> with <QtGui/QApplication>

  • Lifetime Qt Champion

    QApplication is a widgets module class in Qt 5. To be compatible with both Qt 4 and 5 the include statement should not include the module.

  • @Ratzz I changed the #include but the include is still underlined and I get no hints in the editor :-( It seems the the Qt Creator has problem finding the file, whilst make works.

    Please note, that the project compiles correctly with both <QApplication> and <QtGui/QApplication>

    Edit: It works if I clear the sysroot path in the Kit. So obviously the Qt Creator uses the sysroot path to scan for header files. If I leave it empty, the Qt Creator however uses the header files of host and not target, which is wrong. I tried to put the header files to <sysroot>/usr/include/qt4, but it still does not work.

  • Lifetime Qt Champion

    Which version of Qt Creator are we talking about ?

  • @SGaist Qt Creator version is 3.0.1 running on Ubuntu 14.04, Qt 4.8.3

  • Lifetime Qt Champion

    You should consider updating Qt Creator. Current version is 3.5.1

  • I know. Only this version is provided for Ubuntu 14.04. Maybe I could install Qt 5.5 next to current installation in order not to corrupt current Qt, which is used by Ubuntu itself. Btw, do you think the 3.5 solves it or it is just to try? Better than trying different versions I would like to know, where the Qt Creator is looking for the header files.

  • Lifetime Qt Champion

    That you can check in the Kit and Qt Versions for that information

  • I know, but I need to know, where exactly. For example in the kit I have sysroot /<some path>. So in what directories the Qt Creator is looking? Is it /<some path>/usr/include/qt or /<some path>/usr/include/qt4 or different one. Btw I tried to put the Qt headers in these both directories and it didn't work. So where to put the Qt header files in the sysroot folder in order the Qt Creator finds them?

  • Lifetime Qt Champion

    AFAIK, it should use the prefix set at compilation time to search that

Log in to reply