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 ...
随机推荐
- struts2从浅至深(六)contextMap(存取数据)
A:存数据 1.利用ActionContext存数据 这种方式最简便 这是一个购物车案例 把查询来的数据放入到Session中存储起来 2.利用valuestack值栈存数据 把查询出来的数据放入到值 ...
- ESP32应用程序的内存布局
应用程序内存布局 ESP32芯片具有灵活的内存映射功能.本节介绍ESP-IDF在默认情况下如何使用这些功能. ESP-IDF中的应用程序代码可以放置在以下内存区域之一中. IRAM(指令RAM) ES ...
- springMVC 开涛 数据绑定
纸上得来终觉浅,绝知此事要躬行. 一.@requestParam //使用方法URL:?username="sfp" test(@RequestParam(value=" ...
- Bad Day -- Daniel Powter
Bad Day Bad Day (坏天气) 来自 Daniel Powter -- 2005年MTV欧洲音乐奖提名最佳新人, 出自专辑 ...
- EBS trace分析
下载Trace Analyzer,打开bin下的traceanalyzer.bat 即可分析EBS的trace文件,图形化界面,无需tkprof 需要配置javahome,确认java版本为1.6以上 ...
- Android-XML格式描述
XML是W3C公司提出的标准,使用范围非常广阔,在框架的配置,程序的配置,布局文件的定义,网络传输等,无所不在: 以前学Java的时候,对XML的名词定义是,根节点,子节点 等等,而在Android里 ...
- Ubuntu14.04下Pycharm3.4 字体渲染
在ubuntu下搭建了django的开发环境,搭建过程十分简单,Pycharm的安装更简单,下载tar包解压并执行bin目录下的脚本即可,但是看着那个字体真心不爽.于是开始搜索调教. 1.安装打了渲染 ...
- TSQL--删除登陆相关的用户
无二话,上代码 --删除登陆相关的用户 --遍历所有数据库,查找到与登录名相关联的的用户,生成删除脚本 ) SET @loginName='DBA'; DECLARE @comm NVARCHAR(M ...
- .NET Core MemoryCache缓存获取全部缓存键
在Core中不能使用原HttpRuntime.Cache缓存,改为MemoryCache(Microsoft.Extensions.Caching.Memory). 现MemoryCache新版为2. ...
- WPF 捕捉全局异常
public App() { //首先注册开始和退出事件 this.Startup += new StartupEventHandler(App_Startup); this.Exit += new ...