1向导生成
Gui Application
base class QDialog
Next Ctrl+R/Run
修改dialog.ui文件添加控件改属性。
2纯源码编写
空白工程+源文件
View Code
1 #include <QtGui>
2 int main(int argc ,char*argv[])
3 {
4 QApplication app(argc,argv);
5 QDialog *Qd=new QDialog();
6 QLabel *Qlab=new QLabel(Qd);
7 Qlab->setText("hello Qt");
8 Qd->show();
9 return app.exec();
10 }
3 ui文件
空白工程
添加ui文件 加控件改属性
ui对应的头文件ui_xxx.h
加main.cpp
View Code
1 #include <QtGui>
2 #include "ui_dialog.h"
3 int main(int argc,char *argv[])
4 {
5 QApplication app(argc,argv);
6 QDialog *Qd=new QDialog();
7 Ui_Dialog *ui=new Ui_Dialog();
8 ui->setupUi(Qd);
9 Qd->show();
10 return app.exec();
11 }
debug下的exe双击报错,提示缺少dll。添加环境变量qt/bin。