2013-01-10 85 views
8

我剛剛安裝了基於Qt 5.0的Qt Creator 2.6.1。QDialog沒有這樣的文件或目錄 - Qt Windows

我想打開一個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 

還有更多。

我將qmake.exe路徑添加到PATH ...我還需要做其他事嗎?

回答

19

閱讀從Qt4Qt5的轉換指南。 Link1Link2Link3

一個Qt中5主要內部基建變化相比 Qt的圖4是從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> 
5

我有這個問題,做了兩個變化

  1. 回聲 「QT + =小工具」 >> /fileProject.pro

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

先前包括QtGui的

已經足夠,但QT5將widgets分割成更多.h文件,因此有必要包含它們。例如QtMenuBar包含在QtMenu.h中,但現在需要QtMenuBar.h #included

相關問題