我正在使用 Qt5。我写了下面的代码:
#include <QtGui/QApplication>
#include <Qlabel>
int main(int argc, char *argv[]){
QApplication prog(argc, argv);
Qlabel *label = new Qlabel("gametime!");
label->show();
return prog.exec();
}
出现以下问题:-
error: QtGui/QApplication: No such file or directory
最佳答案
QApplication
是 Qt5 Widgets 库的一部分(不是 GUI 库,它提供较低级别的设施)。
添加QT += widgets
给你的.pro
文件,并更改
#include <QtGui/QApplication>
到
#include <QtWidgets/QApplication>
(您应该能够减少到仅 <QApplication>
,因为 QMake 通常会根据 QT
变量中指定的库添加必要的包含路径。)
关于c++ - QT 5 [ 错误 : QtGui/QApplication: No such file or directory],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49526463/