Cannot find include file QtCore?

13,164

Solution 1

You probably have the include directories point to root include directory of Qt, so try:

#include <QtCore/QtCore>

... or... you don't have the include directories refering to Qt in your compiler command line.

Solution 2

This SO question has an answer which worked for me when Visual Studio did not recognize #include statements in my Qt project. While compiling and building worked in my case, the IDE would indicate that the #include line was incorrect and show a message 'Cannot find include file XXX'.

The question linked to above points to a nokia page about intellisense and QT which indicates that Visual Studio should be launched from the "Qt x.xx for Desktop (MSVC 20xx)" command prompt included with the binary distribution of QT. After launching Visual Studio from the QT command prompt my problem went away.

Solution 3

Sounds like your .pro file is configured incorrectly.

Your error's source is the compiler, which is fed the wrong include directories - this is why QtCore can't be found.

This can happen if you don't use qmake (and a plain Makefile instead), CMake and have it configured incorrectly, etc., etc. To be honest, it can have a lot of reasons.

Can you post the contents of your .pro-file or Makefile? And tell us a bit more about more about how you actually start compilation?

Share:
13,164
dfetter88
Author by

dfetter88

Updated on June 17, 2022

Comments

  • dfetter88
    dfetter88 almost 2 years

    I'm writing a multithreaded program in C++, and plan to use QThread. Problem is when I try to #include <QtCore>... I get an error... Cannot find include file QtCore.

    What gives?