Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error : 'QtGui/QMainWindow': No such file or directory : Qt 5.1.1

Tags:

windows

qt5.1

I have installed the Qt5.1.1 and create a new Gui Application. The code in mainwindow.h shows:

#if QT_VERSION >= 0x050000
#include <QtWidgets/QMainWindow>
#else
#include <QtGui/QMainWindow>
#endif

I think it is fine. But when I run it, I have this:

error: C1083: Cannot open include file: 'QtGui/QMainWindow': No such file or directory

I know when I replace

#if QT_VERSION >= 0x050000
#include <QtWidgets/QMainWindow>
#else
#include <QtGui/QMainWindow>
#endif

to

#include <QtWidgets/QMainWindow>

it works.

I just wonder why the default code is wrong and how to make the defauly code right.

like image 316
kalryoma Avatar asked Dec 01 '13 15:12

kalryoma


1 Answers

You may have another option.

You can also add widgets in your .pro file like

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

By adding this line in .pro file, Now you just no need to worry about Qt version and include file like <QtGui/QMainWindow> or <QtWidgets/QMainWindow>

Hope it will useful to you.

like image 118
AB Bolim Avatar answered Oct 04 '22 07:10

AB Bolim