c++ - QT 5 [ 错误 : QtGui/QApplication: No such file or directory]

标签 c++ qt5

我正在使用 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/

相关文章:

c++ - 类型转换 void* 并将其放入 ostringstream

c++ - 由于 gcc -M 选项,Coverity 扫描跳过所有命令并且不扫描任何内容

c++ - 如何获得 LaVectorDouble 对象,它是 LaGenMatDouble 的子矩阵 View ?

c++ - Qt/C++ : What's the best way to call a method asynchronously in Qt event loop without having to write its name as string?

c++ - 如何与子 QProcess 交互?

c++ - QtRPT 连接错误,没有匹配函数调用到 reportWindow::connect

c++ - 我怎样才能改进这个对象的实例化方式?

c++ - 将 QLineEdit 对象的内容保存到字符串变量中 (C++)

c++ - 使用带有继承的 Qt5 新连接语法

c++ - 用于 Qt5 的 GDB pretty-print