C/C++ -- Gui编程 -- Qt库的使用 -- 使用.ui文件
1.创建Qt空工程
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库的使用 -- 使用.ui文件的更多相关文章
- Python -- Gui编程 -- Qt库的使用 -- 配置资源文件
1.源文件(qtRes.py) import sys from PyQt4 import QtCore, QtGui, uic class MyDialog(QtGui.QDialog): def _ ...
- C/C++ -- Gui编程 -- Qt库的使用 -- 理解主窗体构造函数
MyWidget做父窗体 MyWidget的构造函数中可以手动添加组件 Ui::MyWidget存放子部件 Ui::MyWidget执行setupUi()函数为子部件开辟空间,指定父窗体 MyWidg ...
- C/C++ -- Gui编程 -- Qt库的使用 -- 使用自定义类
1.新建空Qt工程 2.新建C++类HelloQt 3.新建ui文件,添加部件,重命名主窗体(对话框)类名HelloQt,构建生成ui头文件 4.修改头文件helloqt.h #ifndef HELL ...
- C/C++ -- Gui编程 -- Qt库的使用 -- 标准对话框
-----mywidget.cpp----- #include "mywidget.h" #include "ui_mywidget.h" #include & ...
- C/C++ -- Gui编程 -- Qt库的使用 -- 信号与槽 -- 欢迎界面
程序运行先显示一个对话框,确定进入主程序 1.新建Qt工程,类MyWidget,基类QWidget 2.新建设计师界面类MyDialog,基类QDialog 3.-----main.cpp----- ...
- C/C++ -- Gui编程 -- Qt库的使用 -- 信号与槽的关联
Qt信号与槽的三种关联方法:1.设计界面关联,编辑信号/槽,自动关联 2.手动关联(1).头文件中定义槽 -----mywidget.h----- #ifndef MYWIDGET_H #define ...
- C/C++ -- Gui编程 -- Qt库的使用 -- Qt5总结
主要变化: 1.与Qt4相比,Qt5可以直接显示中文不需要手工转码2.Qt5模块发生变化,大部分组件并入widgets模块 注意事项:工程文件加一句greaterThan(QT_MAJOR_VERSI ...
- C/C++ -- Gui编程 -- Qt库的使用 -- Qt5试用
1.头文件<QtGui>变成了<QtWidgets> 相应<QtGui/***>变成了<QtWidgets/***> 2.QTextCodec::set ...
- C/C++ -- Gui编程 -- Qt库的使用 -- 使用小写qDebug调试程序
qDebug作为printf不需要头文件 qDebug()作为cout要使用头文件<QDebug> -----debug.cpp----- -----debug.cpp----- #inc ...
随机推荐
- MySQL性能调优与架构设计——第 14 章 可扩展性设计之数据切分
第 14 章 可扩展性设计之数据切分 前言 通过 MySQL Replication 功能所实现的扩展总是会受到数据库大小的限制,一旦数据库过于庞大,尤其是当写入过于频繁,很难由一台主机支撑的时候,我 ...
- (并查集)小希的迷宫 --HDU -- 1272
链接: http://acm.hdu.edu.cn/showproblem.php?pid=1272 http://acm.hust.edu.cn/vjudge/contest/view.action ...
- [php] cookie 跨域共享
<?php // m.hinabian.com class Controller_Cookie extends Hnb_Base_Controller { public function ini ...
- Quartz.net 起步
安装 Quartz 程序包 使用 nuget 命令行安装 Quartz: Install-Package Quartz 如果使用 JSON 序列化,使用 nuget 安装 Quartz.Seriali ...
- [ACM_水题] UVA 12502 Three Families [2人干3人的活后分钱,水]
Three Families Three families share a garden. They usually clean the garden together at the end o ...
- sql 中如何查询某一列的数据在另一个表中有没有?
假设表table1,列a,表table2,列bselect a from table1where a not in(select b from table2)
- DataAnnotations 验证
转自:http://blog.sina.com.cn/s/blog_c21a857b0102wcus.html 常用的 DataAnnotations 1.Required :属性值必须非空或者不能只 ...
- eclipse创建Maven工程没有Maven Dependencies
记一次eclipse创建Maven工程没有Maven Dependencies的坑 Eclipse版本:luna版 maven用的3.5.0 配置本文不提. 这辆天用Eclipse创建maven工程 ...
- 三,memcached服务的两种访问方式
memcached有两种访问方式,分别是使用telnet访问和使用php访问. 1,使用telnet访问memcacehd 在命令提示行输入, (1)连接memcached指令:telnet 127. ...
- flask-mysqldb安装时EnvironmentError: mysql_config not found
安装时候的日志如下: sh: : mysql_config: not found Traceback (most recent call last): File , in <module> ...