Hello Qt

Posted on 2016-03-31 22:31  徐岩  阅读(131)  评论(0)    收藏  举报

版本: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();
}