AI摘要
本文介绍了在CLion中使用Qt框架编写第一个C++程序的方法。通过创建QApplication对象,并实例化QLabel和QPushButton控件,展示了如何构建包含按钮与标签的窗口,最后通过application.exec()使程序进入事件循环。
Clion使用qt框架的第一个c++程序
源代码
编写一个按钮和标签的窗口
#include "QApplication"
#include "QLabel"
#include "QPushButton"
using namespace std;
int main(int argc, char *argv[]) {
//创建QT的应用程序对象
QApplication application(argc,argv);
//创建标签控件
QLabel qLabel("标签");
//显示标签控件
qLabel.show();
//创建按钮控件
QPushButton qPushButton("按钮");
//显示按钮控件
qPushButton.show();
//让应用程序进入事件
return application.exec();
}
评论 (0)