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 ...
随机推荐
- github/gitlab添加多个ssh key
系统:macOS X 由于公司的代码管理放在了gitlab.com上,所以添加了一个ssh key, 生成ssh key的代码如下: 1.$ ssh-keygen -t rsa -C “yourema ...
- Linux 用 sftp scp命令 互传文件
sftp它类似于 ftp, 但它进行加密传输,比FTP有更高的安全性. sftp 是SSH服务的子程序 常用命令 pwd 查看当前工作目录 ls 查看远程当前目录下的所以文件或者目录信息 lls 查看 ...
- hdu 4981
中位数是否大于平均数 水题 #include <cstdio> #include <cstdlib> #include <cmath> #include <c ...
- Android-Activity跳转时动画
Activity跳转时动画,是在跳转Activity,或者在Activity结束返回 等,用到的进入效果: 第一种效果展示: 第一个Activity的代码: package liudeli.activ ...
- 查看Linux服务器被映射的公网ip
查看Linux服务器被映射的公网ip 现在云服务器非常流行,不仅企业甚至是个人都可能拥有自己的云服务器,但是目前的云服务器厂商提供的公网IP大都是映射而来,所以在Linux服务器上执行ifconf ...
- LINQ to XML基本操作
Linq to XML同样是对原C#访问XML文件的方法的封装,简化了用xpath进行xml的查询以及增加,修改,删除xml元素的操作. LINQ to XML 三个最重要类:XElement.XAt ...
- GridView1 RowDataBound
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == ...
- 自己从0开始学习Unity的笔记 I (C#字符串转换为数字)
我基本上从0开始学习编程,运算符基本上跳过,因为知道了 “=”这个符号相当于赋值,然后“==”才是等于,其他和普通运算符号差不都,也就跳过了. 最基础的赋值那种,我看了下代码,似乎没什么难度,估计新手 ...
- Web 平台安装程序 5.0(Microsoft Web Platform Installer) 由于修改常用选择不正确导致打开就报错
如图: 解决方案.第一步先卸载 Web 平台安装程序 5.0 第二步 将你添加配的文件删除 第三步:重新安装就可以了
- 深入理解Aspnet Core之Identity(2)
主题: 我将继续介绍Identity的账户简单管理,即是增删改查.我会只介绍增加和删除,修改功能代码我会上传到我的github上, 创建用户: 1.我在Model文件夹创建一个 CreateModel ...