我的主目录中有一个目录为 qt-everywhere-opensource-src-4.8.2。此目录包含基本的 QT 包,但问题是,当我编译主目录中存在的普通 Qt 文件时,它显示找不到相应 QT 包的错误。但是,当我尝试编译普通 c 文件时g++ 生成的 gcc 和 c++ 文件,那么它不会出错。我只想知道如何包含目录中存在的那些包。我要编译的文件是:-
#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