将
#include <QMainWindow>
改为
#include <QtWidgets>
并且在.pro文件中加上
1 QT += core gui 2 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
Qt 错误:QMainWindow: No such file or directory 解决方法
原文:https://www.cnblogs.com/ybqjymy/p/12937871.html