Python -- Gui编程 -- Qt库的使用 -- 配置资源文件
1.源文件(qtRes.py)
import sys
from PyQt4 import QtCore, QtGui, uic
class MyDialog(QtGui.QDialog):
def __init__(self):
QtGui.QDialog.__init__(self)
uic.loadUi('qtRes.ui', self)
class MyWindow(QtGui.QWidget):
def __init__(self):
QtGui.QWidget.__init__(self)
self.setWindowTitle('QtRes')
self.resize(485, 300)
self.btn = QtGui.QPushButton('Click Here')
self.grid = QtGui.QGridLayout()
self.grid.addWidget(self.btn)
self.setLayout(self.grid)
self.connect(self.btn, QtCore.SIGNAL('clicked()'), self.onBtn)
def onBtn(self):
mydialog = MyDialog()
r = mydialog.exec_()
if r:
self.btn.setText(mydialog.txt.text())
app = QtGui.QApplication(sys.argv)
mywindow = MyWindow()
mywindow.show()
app.exec_()
2.资源文件(qtRes.ui) -- 使用QT设计师编辑,
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>359</width>
<height>212</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
<rect>
<x>-30</x>
<y>140</y>
<width>341</width>
<height>32</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="QLabel" name="lbl">
<property name="geometry">
<rect>
<x>80</x>
<y>60</y>
<width>54</width>
<height>12</height>
</rect>
</property>
<property name="text">
<string>Input</string>
</property>
</widget>
<widget class="QLineEdit" name="txt">
<property name="geometry">
<rect>
<x>190</x>
<y>60</y>
<width>113</width>
<height>20</height>
</rect>
</property>
</widget>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>Dialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>Dialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

Python -- Gui编程 -- Qt库的使用 -- 配置资源文件的更多相关文章
- Python -- Gui编程 -- Qt库的使用 -- 菜单与对话框
1.菜单 import sys from PyQt4 import QtCore, QtGui class MyWindow(QtGui.QMainWindow): def __init__(self ...
- Python -- Gui编程 -- Qt库的使用 -- 布局与基本控件
1.垂直布局,水平布局和网格布局 import sys from PyQt4 import QtCore, QtGui class MyWindow(QtGui.QWidget): def __ini ...
- C/C++ -- Gui编程 -- Qt库的使用 -- 使用.ui文件
1.创建Qt空工程 2.添加Qt设计师界面,无按钮对话框helloqt.ui 3.编辑界面,添加部件,修改对话框对象名为HelloQt <?xml version="1.0" ...
- C/C++ -- Gui编程 -- Qt库的使用 -- 理解主窗体构造函数
MyWidget做父窗体 MyWidget的构造函数中可以手动添加组件 Ui::MyWidget存放子部件 Ui::MyWidget执行setupUi()函数为子部件开辟空间,指定父窗体 MyWidg ...
- 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 ...
随机推荐
- nodejs中使用mongodb quickstart
nodejs中使用mongodb quickstart node 中使用mongodb的quick start.整理的官网crud简单例子. 在百度找了几篇帖子都有问题,所以直接看官网了. 连接Mon ...
- 简单的nginx模拟网站的负载均衡
环境:nginx1.10.3 虚拟机环境:3台centos7虚拟机 将148机器作为转发服务器配置如下 监听80端口,在http里面配置如下 将edc.com分别转发到149和150的服务器上 本地主 ...
- obj-c的优缺点
优点: 1) Cateogies : 类别 2) Posing : 扮演 3) 动态识别 : 编译时与运行时动态识别类型 4) 指标计算 : 指针计算 指针的 +- * / 5) 弹性信息传递 : 某 ...
- [翻译] FastReport 格式化和突出显示
一:格式化一个值 聚合函数的一个特征是,返回的数值没有格式化,如如下例子所示,它使用"SUM": 数据字段通常返回一个格式化的值,这是一个没有任何变化的"文本" ...
- 微软DevOps软件开发高级培训课程(深圳站) 2016.04.06
深圳特区云集了国内众多大型IT企业,作为北上广深的一线城市,当之无愧! 我们在深圳同方信息港的微软办公室是举行培训,60人的培训教室,生生被挤满了80人,过道都被全部占用了.可惜由于换了电脑,把照片搞 ...
- .NET在IE10下的回传BUG修复
以前我也没注意到,直到有次公司新配了台机器做测试服务器,在测试过程中意外发现凡是涉及PostBack的操作仅在IE10下都无效,其他版本浏览器都没有问题,本机调试也没有问题. 这也就是说在程序相同的情 ...
- linux中权限
$ ls -l /bin/bash -rwxr-xr-x 1 root wheel 430540 Dec 23 18:27 /bin/bash -rwxr-xr-x 包含该特殊文件的权限的符号表示.该 ...
- Redis安装步骤 - linux系统下
https://blog.csdn.net/lzj3462144/article/details/70973368 https://www.cnblogs.com/pyyu/p/9467279.htm ...
- Restful认识和 IK分词器的使用
什么是Restful风格 Restful是一种面向资源的架构风格,可以简单理解为:使用URL定位资源,用HTTP动词(GET,POST,DELETE,PUT)描述操作. 使用Restful的好处: 透 ...
- linux常用命令大全(linux基础命令入门到精通+命令备忘录+面试复习+实例)
作者:蓝藻(罗蓝国度) 创建时间:2018.7.3 编辑时间:2019.4.29 前言 本文特点 授之以渔:了解命令学习方法.用途:不再死记硬背,拒绝漫无目的: 准确无误:所有命令执行通过(环境为ce ...