#include <QMainWindow> 

改为

#include <QtWidgets>

并且在.pro文件中加上

1 QT += core gui
2 greaterThan(QT_MAJOR_VERSION, 4): QT += widgets