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

时间:2013-01-10 14:44:34

标签: windows qt qt-creator

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

我试图打开4.8上的项目,但我无法编译它。它不断向我显示错误#34;而不是这样的文件或目录"。

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

还有更多。

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

2 个答案:

答案 0 :(得分:19)

阅读从Qt4Qt5的过渡指南。 Link1 Link2 Link3

  

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

     

从Qt 4移植到Qt 5的另一个包含相关问题正在处理中   with包含已移至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>

答案 1 :(得分:6)

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

  1. echo“QT + = widgets”&gt;&gt; /fileProject.pro

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

  3. 之前包括QtGui的

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