QT学习之路DAY1之初学QT的小项目
以下所有代码均利用软件QT5编写
项目一:Hello world!
利用QTcreator创建项目
修改main.cpp代码为
1 #include "mainwindow.h" 2 #include <QApplication> 3 #include <QLabel> 4 5 int main(int argc, char *argv[]) 6 { 7 QApplication a(argc, argv); 8 QLabel *label = new QLabel("Hello, world!"); 9 label->show(); 10 11 return a.exec(); 12 }
运行即可
让Hello变为红色
改变main.cpp的代码
#include "mainwindow.h" #include <QApplication> #include <QLabel> int main(int argc, char *argv[]) { QApplication a(argc, argv); QLabel *label = new QLabel("<h2><font color='red'>Hello</font>, world! <h2>"); label->show(); return a.exec(); }