介绍使用Qt Designer,从简单的hello qt程序开始,(假设我们已安装好Qt)
1、新建文件夹 helloQT。
2、打开qt designer。点击“应用程序”-“编程”-“Qt Designer”;或者在终端里输入命令:designer。
3、选择“File”--“New”,选择“Widget”,然后“Create”。
4、拖入“PushButton” 和“Label”。
5、保存为 helloQT.ui ,然后关闭 qt designer 。
6、在helloQT文件夹里右击打开终端,输入命令:uic helloQT.ui -o ui_helloQT.h
7、编写程序,在helloQT文件夹里:
1) 新建文件main.cpp。输入程序:
#include
#include "helloQT.h"
intmain(intargc,char*argv[])
{
QApplication a(argc,argv);
helloQT hello;
hello.show();
returna.exec();
}
2) 新建文件helloQT.h。输入程序:
#ifndef HELLOQT_H
#define HELLOQT_H
#include
namespace Ui{
class Form;
}
class helloQT:public QWidget
{
Q