#包含 -->没有这样的文件或目录

时间:2020-12-07 02:04:37

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

我使用Qt创建者,这条线是由Qt创建者自动生成的:

#include <QtGui/QApplication>

# include < QtGui / QApplication >

But, why am I getting this message?

但是,为什么我要得到这个信息呢?

QtGui/QApplication>: No such file or directory

QtGui/QApplication>:没有这样的文件或目录

5 个解决方案

#1


14  

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

您可以尝试向项目文件添加“声明性”:

QT += gui declarative

then

然后

#include <QApplication>

It helps me

它帮助我

#2


13  

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

根据Qt-version (5), QtGui被移动到QtWidgets;所以它变成了

#include < QtWidgets/QApplication>

# include < QtWidgets / QApplication >

#3


5  

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

#4


3  

This a version problem.to fix,

这一个版本的问题。修复,

  • you need to add QT += widgets in the .pro file
  • 您需要在.pro文件中添加QT += widgets
  • and run qmake

    和运行qmake

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

    使用#include 代替#include

#5


2  

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.

我遇到了同样的问题。从visual studio使用命令提示(2010),我将提示符的路径更改为Qt所在的位置,即:\Qt。在那里,我设置了QTDIR环境变量。

c:\Qt> setx QTDIR C:\Qt

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.

确保VS在此期间关闭。当您重新打开它时,将检测到所有头部。

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

我希望我的解决方案有一天会对任何人都有帮助。欢呼:)

#1


14  

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

您可以尝试向项目文件添加“声明性”:

QT += gui declarative

then

然后

#include <QApplication>

It helps me

它帮助我

#2


13  

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

根据Qt-version (5), QtGui被移动到QtWidgets;所以它变成了

#include < QtWidgets/QApplication>

# include < QtWidgets / QApplication >

#3


5  

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

#4


3  

This a version problem.to fix,

这一个版本的问题。修复,

  • you need to add QT += widgets in the .pro file
  • 您需要在.pro文件中添加QT += widgets
  • and run qmake

    和运行qmake

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

    使用#include 代替#include

#5


2  

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.

我遇到了同样的问题。从visual studio使用命令提示(2010),我将提示符的路径更改为Qt所在的位置,即:\Qt。在那里,我设置了QTDIR环境变量。

c:\Qt> setx QTDIR C:\Qt

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.

确保VS在此期间关闭。当您重新打开它时,将检测到所有头部。

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

我希望我的解决方案有一天会对任何人都有帮助。欢呼:)