实现HelloWorld有2种方法。

第一种在mainwindow.ui直接添加Label且写上“HelloWorld”。

QT学习之-HelloWorld

 

第二种是代码直接实现

#include "mainwindow.h"
#include <QApplication>
#include <QtWidgets/QLabel>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QLabel label("HelloWorld \n");
    label.show();
//    MainWindow w;
//    w.show();

    return a.exec();
}

  QT学习之-HelloWorld

 

 

如果要直接运行.exe可执行程序的话 要把C:\Qt\Qt5.5.0\5.5\mingw492_32\bin添加到环境变量

QT学习之-HelloWorld

 添加环境变量的步骤,计算机属性->高级设置->环境变量->添加Path=C:\Qt\Qt5.5.0\5.5\mingw492_32\bin

相关文章: