1 代码
#include <QtWidgets/QLabel> #注意这里一定要加QtWidgets,不然编译不通过
#include <QtWidgets/QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel;
label->setText("helloahkhgksa");
label->show();
return app.exec();
}
2 生成.pro文件
打开安装Qt生成的命令工具
运行qmake -project
编辑.pro文件
######################################################################
# Automatically generated by qmake (3.1) Sun Oct 6 12:05:15 2019
######################################################################
TEMPLATE = app
TARGET = 0_hello
INCLUDEPATH += .
# Input
SOURCES += main.cpp
QT += widgets #新添加
3 生成Makefile文件
qmake
4 生成exe文件
mingw32-make