Hello Qt

时间:2023-03-08 17:50:59

版本:Qt 5.5.1 Windows

参考: C++ GUI Programming with Qt 4 Second Edition

1. 打开 Qt Creator,File -> New Project -> Other Project -> Empty qmake project

2. 建立 HelloQt.pro,然后添加 main.cpp

3. 在 HelloQt.pro 中加入 QT += widgets

最终如下所示:

HelloQt.pro

SOURCES += \
main.cpp QT += widgets

main.cpp

#include <QApplication>
#include <QLabel> int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QLabel *label = new QLabel("<h2><i>Hello</i> "
"<font color=red>Qt!</font></h2>");
label->show();
return app.exec();
}