C/C++ -- Gui编程 -- Qt库的使用 -- 使用.ui文件
2014-05-06 01:43
483 查看
1.创建Qt空工程
2.添加Qt设计师界面,无按钮对话框helloqt.ui
3.编辑界面,添加部件,修改对话框对象名为HelloQt
4.构建生成Ui头文件''ui_helloqt.h''
5.添加main.cpp,使用构建生成的ui头文件
备注:
ui对象也可以用Ui_HelloQt实例化,因为Ui::HelloQt完全没有更改地继承自Ui_HelloQt
命令行下编译.ui文件
uic -o 目标文件.h 源文件.ui
比如 uic -o ui_helloqt.h helloqt.ui
2.添加Qt设计师界面,无按钮对话框helloqt.ui
3.编辑界面,添加部件,修改对话框对象名为HelloQt
<?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>HelloQt</class> <widget class="QDialog" name="HelloQt"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>400</width> <height>300</height> </rect> </property> <property name="windowTitle"> <string>Dialog</string> </property> <widget class="QLabel" name="lbl"> <property name="geometry"> <rect> <x>170</x> <y>140</y> <width>54</width> <height>12</height> </rect> </property> <property name="text"> <string>哈喽Qt</string> </property> </widget> </widget> <resources/> <connections/> </ui>
4.构建生成Ui头文件''ui_helloqt.h''
5.添加main.cpp,使用构建生成的ui头文件
#include "ui_helloqt.h" int main(int argc, char * argv[]) { QApplication app(argc, argv); QDialog dlg; Ui::HelloQt ui; ui.setupUi(&dlg); dlg.show(); return app.exec(); }
备注:
ui对象也可以用Ui_HelloQt实例化,因为Ui::HelloQt完全没有更改地继承自Ui_HelloQt
namespace Ui { class HelloQt: public Ui_HelloQt {}; } //
命令行下编译.ui文件
uic -o 目标文件.h 源文件.ui
比如 uic -o ui_helloqt.h helloqt.ui
相关文章推荐
- C/C++ -- Gui编程 -- Qt库的使用 -- Qt5试用
- C/C++ -- Gui编程 -- Qt库的使用 -- 构造函数中添加组件
- C/C++ -- Gui编程 -- Qt库的使用 -- 使用自定义类
- C/C++ -- Gui编程 -- Qt库的使用 -- Qt5总结
- C/C++ -- Gui编程 -- Qt库的使用 -- Qt窗体的类型状态布局
- C/C++ -- Gui编程 -- Qt库的使用 -- 组件大杂烩
- C/C++ -- Gui编程 -- Qt库的使用 -- Qt编码问题
- C/C++ -- Gui编程 -- Qt库的使用 -- 使用小写qDebug调试程序
- C/C++ -- Gui编程 -- Qt库的使用 -- QtWidget
- C/C++ -- Gui编程 -- Qt库的使用 -- 使用图片与动画
- C/C++ -- Gui编程 -- Qt库的使用 -- HelloWorld
- C/C++ -- Gui编程 -- Qt库的使用 -- 对话框QDialog
- C/C++ -- Gui编程 -- Qt库的使用 -- 信号与槽的关联
- C/C++ -- Gui编程 -- Qt库的使用 -- 纯代码实现信号槽
- C/C++ -- Gui编程 -- Qt库的使用 -- 标准对话框
- Python -- Gui编程 -- Qt库的使用 -- 配置资源文件
- C/C++ -- Gui编程 -- Qt库的使用 -- 信号与槽 -- 欢迎界面
- C/C++ -- Gui编程 -- Qt库的使用 -- 理解主窗体构造函数
- 《Java程序设计》第16周周四:GUI编程及文件对话框的使用(项目二)
- C++ GUI编程---使用SmartWin++