Qt 5.3. QtWidgets: No such file or directory #include <QtWidgets>

Ufx picture Ufx · Jul 10, 2014 · Viewed 45.5k times · Source

I want to compile Qt example. I get error QtWidgets: No such file or directory #include

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - does not help
QT += widgets                                   - does not help
INCLUDEPATH += /opt/Qt/5.3/Src/qtbase/include/  - does not help

Qt 5.3. Ubuntu 14.04 x64.

Answer

lpapp picture lpapp · Jul 10, 2014

You need to double check that you completed all these steps:

  • Module installed

  • greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

  • You re-run the Qt 5 qmake.

Having said that, I would like to remind you that including the whole module is not a good idea as it includes all the widgets related things. Try to narrow it down to the headers that you really need.