0
点赞
收藏
分享

微信扫一扫

Qt命令行运行helloworld

残北 2022-11-23 阅读 113


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

5 运行exe文件

Qt命令行运行helloworld_#include


举报

相关推荐

0 条评论