QDialog不是这样的文件或目录 - Qt Windows

Nic*_*ott 8 windows qt qt-creator

我刚刚安装了基于Qt 5.0的Qt Creator 2.6.1.

我正在尝试打开4.8上的项目,但我无法编译它.它一直向我显示"不是这样的文件或目录"的错误.

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

error: C1083: Cannot open include file: 'QDialog': No such file or directory 

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

error: C1083: Cannot open include file: 'QWidget': No such file or directory
Run Code Online (Sandbox Code Playgroud)

还有很多.

我将qmake.exe路径添加到PATH ...我还需要做其他事吗?

pne*_*zis 19

从阅读过渡指南Qt4Qt5.Link1 Link2 Link3

与Qt 4相比,Qt 5中的主要内部基础结构变化之一是将小部件从QtGui模块拆分为新的QtWidgets模块.这显然至少需要对系统进行更改,但也会导致下游需要添加之前不需要的标头包含,因为这些包含已从现在保留在QtGui模块中的标头中删除.

从Qt 4移植到Qt 5的另一个包含相关问题是处理已转移到QtWidgets模块的类的包含.而基于Qt 4的代码可能会使用

#include <QtGui/QWidget>
This must be updated to either

#include <QtWidgets/QWidget>
Or more portably (Which works in Qt 4 and Qt 5):

#include <QWidget>
Run Code Online (Sandbox Code Playgroud)


小智 6

我遇到了这个问题,做了两处修改

  1. echo"QT + = widgets">> /fileProject.pro

  2. 在包含QDialog声明的文件中添加#include QDialog

以前包括QtGui就足够了,但QT5将小部件拆分成更多.h文件,因此必须包含它们.例如QtMenuBar包含在QtMenu.h中,但现在要求QtMenuBar.h为#included