C++ 致命错误:QtGui/QApplication:没有那个文件或目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5535661/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
fatal error: QtGui/QApplication: No such file or directory
提问by Simplicity
I'm using Qt Creator, and this line is generated automatically by the Qt Creator:
我正在使用 Qt Creator,这一行是由 Qt Creator 自动生成的:
#include <QtGui/QApplication>
#include <QtGui/QApplication>
But, why am I getting this message?
但是,为什么我会收到此消息?
QtGui/QApplication: No such file or directory
QtGui/QApplication: No such file or directory
回答by Miguel Rodriguez
Depending on the Qt-version (5) QtGui was moved to QtWidgets; so it becomes
根据 Qt 版本 (5) QtGui 移至 QtWidgets;所以它变成
#include <QtWidgets/QApplication>
回答by VeroLom
You can try to add 'declarative' to the Project file:
您可以尝试在项目文件中添加“声明性”:
QT += gui declarative
then
然后
#include <QApplication>
It helps me
它帮助到我
回答by Simplicity
Issue solved.
问题解决了。
I added this to PATH
: C:\Qt\2010.05\qt\bin
我将此添加到PATH
:C:\Qt\2010.05\qt\bin
Instead of: C:\Qt\2010.05\bin
代替: C:\Qt\2010.05\bin
As the latter didn't contain qmake.exe
由于后者不包含 qmake.exe
回答by Sachith
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>
- 你需要
QT += widgets
在.pro
文件中添加 并运行
qmake
并且还使用
#include <QApplication>
代替#include <QtGui/QApplication>
回答by NightFury
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.
我遇到了同样的问题。从使用命令提示符(2010)的 Visual Studio,我将提示符的路径更改为我的 Qt 所在的位置,即C:\Qt
. 在那里我设置了QTDIR
环境变量。
c:\Qt> setx QTDIR C:\Qt
c:\Qt> setx QTDIR C:\Qt
Then message was displayed:
然后显示消息:
SUCCESS: Specified value was saved.
SUCCESS: Specified value was saved.
Make sure VS is closed during this. When you reopen it, all headers will be detected.
确保在此期间关闭 VS。当您重新打开它时,将检测到所有标题。
I hope my solution will help anyone someday. Cheers :)
我希望我的解决方案有一天能帮助任何人。干杯:)