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 ...
 
随机推荐
- FuelPHP 简体中文手册
			
FuelPHP中文手册 FuelPHP是一个简单的.灵活的.社区驱动的PHP 5.3 web框架,它基于其他框架的最佳思想,是一个全新的开始. 他的诞生源自于很多开发社区对于现有开发框架的不满,Fue ...
 - java web基础之mvc模式设计(一)--使用httpservlet实现mvc分层设计,DAO层使用的是dbutils实现与数据库的链接
			
一:1.最终的实现效果图: 2.案例的目录结构: 3.案例中使用到的jar包: 二:案例的链接数据库的层次结构关系:数据库是:mysql ,数据库名字:dsm,表格名字:customers 数据库表格 ...
 - 团队项目第六周——Alpha阶段项目复审(名字很难想队)
			
Alpha阶段项目复审 小组 优点 缺点 排名 小谷围驻广东某工业719电竞大队 一个贴近大学生生活的二手交易平台.界面美观功能完善. 部分功能未完善,没有第三方登录 1 中午吃啥队 系统完善,界面简 ...
 - C++实现wc.exe程序
			
github项目地址:https://github.com/insomniali/wc 基本功能 wc.exe -c file 统计文件file的字符数 [实现] wc.exe -w fil ...
 - 获取Oracle EBS数据库跟踪文件方法
			
http://www.orapub.cn/posts/1624.html 一.以下在Oracle APP中执行: 1) Set the Profile Option: ‘Initialization ...
 - 检测Linux服务器端口是否开通
			
现如今云服务器已经是大势所趋,国内比较著名的云服务器厂商有阿里.腾讯,国外有aws,尽管有的公司目前为止还是使用的物理机,但是无论你是使用的云服务器还是物理机,在运行服务时都必不可少的需要监听到指定的 ...
 - Nodejs异步框架——async
			
上次的网页爬虫写完后,又打算做一个爬图的工具.前两天已经写好了代码.思路如下: 分析页面还是采用cheerio,对<div>中的img进行分析抽取,拿到图片的url.然后用childpro ...
 - NLayerAppV3--DDD之领域层
			
回顾:NLayerAppV3是一个使用.net 2.1实现的经典DDD的分层架构的项目. NLayerAppV3是在NLayerAppV2的基础上,使用.net core2.1进行重新构建的:它包含了 ...
 - C#基础复习(1) 之 Struct与Class的区别
			
参考资料 [1] 毛星云[<Effective C#>提炼总结] https://zhuanlan.zhihu.com/p/24553860 [2] <C# 捷径教程> [3] ...
 - 修改ActiveReports验证文字“给不能为 null 的参数指定一个 null 值”
			
转:http://gcdn.gcpowertools.com.cn/showtopic-13759.html ActiveReports官方网站:http://www.gcpowertools.com ...