fatal error: QtGui/QApplication: No such file or d

2020-07-02 09:46发布

I'm using Qt Creator, and this line is generated automatically by the Qt Creator:

#include <QtGui/QApplication>

But, why am I getting this message?

QtGui/QApplication: No such file or directory

标签: c++ qt
5条回答
\"骚年 ilove
2楼-- · 2020-07-02 10:10

Issue solved.

I added this to PATH: C:\Qt\2010.05\qt\bin

Instead of: C:\Qt\2010.05\bin

As the latter didn't contain qmake.exe

查看更多
ゆ 、 Hurt°
3楼-- · 2020-07-02 10:12

Depending on the Qt-version (5) QtGui was moved to QtWidgets; so it becomes

#include <QtWidgets/QApplication>
查看更多
4楼-- · 2020-07-02 10:22

I had got same problem. From visual studio using Command Prompt(2010), I changed the path of prompt to where my Qt resides i.e. C:\Qt. There I set QTDIR environment variable.

c:\Qt> setx QTDIR C:\Qt

Then message was displayed:

SUCCESS: Specified value was saved.

Make sure VS is closed during this. When you reopen it, all headers will be detected.

I hope my solution will help anyone someday. Cheers :)

查看更多
Deceive 欺骗
5楼-- · 2020-07-02 10:24

You can try to add 'declarative' to the Project file:

QT += gui declarative

then

#include <QApplication>

It helps me

查看更多
时光不老,我们不散
6楼-- · 2020-07-02 10:27

This is a version problem.to fix,

  • you need to add QT += widgets in the .pro file
  • and run qmake

  • and also use #include <QApplication> instead of #include <QtGui/QApplication>

查看更多
登录 后发表回答