我在我的主目錄有一個目錄爲qt-everywhere-opensource-src-4.8.2。 這個目錄包含基本的QT包和所有,但問題是,當我編譯一個正常的Qt文件存在於主目錄時,它顯示錯誤,相應的QT包沒有找到。但是,當我嘗試編譯一個正常的C文件由gcc和C++文件通過g ++,然後它沒有錯誤。 我只想知道如何包含目錄中存在的那些包。 我這我試圖編譯的文件是: -包括QT包
#include <QApplication>
#include <QWidget>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QWidget window;
window.resize(250, 150);
window.setWindowTitle("Simple example");
window.show();
return app.exec();
}
錯誤=
demo.cpp:1:24: error: QApplication: No such file or directory
demo.cpp:2:19: error: QWidget: No such file or directory
demo.cpp: In function âint main(int, char**)â:
demo.cpp:6: error: âQApplicationâ was not declared in this scope
demo.cpp:6: error: expected â;â before âappâ
demo.cpp:8: error: âQWidgetâ was not declared in this scope
demo.cpp:8: error: expected â;â before âwindowâ
demo.cpp:10: error: âwindowâ was not declared in this scope
demo.cpp:14: error: âappâ was not declared in this scope
能否請您編輯您的問題包括你得到的錯誤? –
qt-everywhere-opensource-src-4.8.2是Qt_source_。你必須建立它來獲得qmake二進制和庫。通過軟件包管理器(在Linux上)安裝它或者下載QtSDK(在Windows上)可能會更方便。 – Claudio
轉至此網站:http://doc-snapshot.qt-project.org/4.8/installation.html並確保您已正確完成所有步驟。 – MrFox