建立QT工程时,由于QT4兼容性的问题,出现关于“fatal error: QApplication: No such file or directory“错误

解决办法也很简单:
在工程的 .pro file: 添加:
QT += core gui widgets

如果还没有用,则 将#include <QApplication>换成
#include <QtWidgets/QApplication>

例如:

#include <QtWidgets/QApplication>   
#include <QtWidgets/QLabel>
int main(int argc,char *argv[])
{ 
    QApplication app(argc,argv); 
    QLabel *label = new QLabel("Hello Lover雪");
    label->show();
    return app.exec();
}

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-28
  • 2022-12-23
  • 2021-12-02
  • 2022-12-23
  • 2021-05-07
  • 2022-01-10
相关资源
相似解决方案