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库的使用 -- 配置资源文件的更多相关文章

  1. Python -- Gui编程 -- Qt库的使用 -- 菜单与对话框

    1.菜单 import sys from PyQt4 import QtCore, QtGui class MyWindow(QtGui.QMainWindow): def __init__(self ...

  2. Python -- Gui编程 -- Qt库的使用 -- 布局与基本控件

    1.垂直布局,水平布局和网格布局 import sys from PyQt4 import QtCore, QtGui class MyWindow(QtGui.QWidget): def __ini ...

  3. C/C++ -- Gui编程 -- Qt库的使用 -- 使用.ui文件

    1.创建Qt空工程 2.添加Qt设计师界面,无按钮对话框helloqt.ui 3.编辑界面,添加部件,修改对话框对象名为HelloQt <?xml version="1.0" ...

  4. C/C++ -- Gui编程 -- Qt库的使用 -- 理解主窗体构造函数

    MyWidget做父窗体 MyWidget的构造函数中可以手动添加组件 Ui::MyWidget存放子部件 Ui::MyWidget执行setupUi()函数为子部件开辟空间,指定父窗体 MyWidg ...

  5. C/C++ -- Gui编程 -- Qt库的使用 -- 标准对话框

    -----mywidget.cpp----- #include "mywidget.h" #include "ui_mywidget.h" #include & ...

  6. C/C++ -- Gui编程 -- Qt库的使用 -- 信号与槽 -- 欢迎界面

    程序运行先显示一个对话框,确定进入主程序 1.新建Qt工程,类MyWidget,基类QWidget 2.新建设计师界面类MyDialog,基类QDialog 3.-----main.cpp----- ...

  7. C/C++ -- Gui编程 -- Qt库的使用 -- 信号与槽的关联

    Qt信号与槽的三种关联方法:1.设计界面关联,编辑信号/槽,自动关联 2.手动关联(1).头文件中定义槽 -----mywidget.h----- #ifndef MYWIDGET_H #define ...

  8. C/C++ -- Gui编程 -- Qt库的使用 -- Qt5总结

    主要变化: 1.与Qt4相比,Qt5可以直接显示中文不需要手工转码2.Qt5模块发生变化,大部分组件并入widgets模块 注意事项:工程文件加一句greaterThan(QT_MAJOR_VERSI ...

  9. C/C++ -- Gui编程 -- Qt库的使用 -- Qt5试用

    1.头文件<QtGui>变成了<QtWidgets> 相应<QtGui/***>变成了<QtWidgets/***> 2.QTextCodec::set ...

随机推荐

  1. (回文串 Manacher )Girls' research -- hdu -- 3294

    http://acm.hdu.edu.cn/showproblem.php?pid=3294 Girls' research Time Limit:1000MS     Memory Limit:32 ...

  2. 转换图片为base64

    既然有了解析base64图片,那么就一定会有将图片编码格式成base64,其中解码base64用BASE64Decoder,而编码base64用BASE64Encoder, 上代码: //图片转化成b ...

  3. hdu4417(Super Mario)—— 二分+划分树

    Super Mario Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  4. 对C++里面 的知识积累:

    unique()[去重函数] unique()是C++标准库函数里面的函数,其功能是去除相邻的重复元素(只保留一个),所以使用前需要对数组进行排序 上面的一个使用中已经给出该函数的一个使用方法,对于长 ...

  5. Html隐藏占空间与隐藏不占空间

    隐藏不占用空间: display:none; 以下为示例代码: <span style="display:none;"> 获取中</span> 隐藏占用空间 ...

  6. C# 实现图片压缩

    代码: private static ImageCodecInfo GetImageCodecInfo(ImageFormat imageFormat) { ImageCodecInfo[] imag ...

  7. WPF之坑——surface触控失灵之谜

    本次又遇到了WPF编写触控程序的一个问题,虽然已解决,但原因确搞不太明白,希望有大神看到这篇文章帮我解答. 在项目中实现了自己定义的icommandsource,因为需要对触控有特殊需求,控件对鼠标与 ...

  8. Azure认知服务的实际应用-资讯采集推送

    Azure认知服务的实际应用-资讯采集推送 演示 实现的是通过使用各种azure服务,每天自动获取资讯.博客,定时推送到公众号的功能! 微信公众号搜索TechViews,或直接扫描二维码关注,每天推送 ...

  9. PageAdmin CMS网站制作教程实例:如何制作一个报名表?

    PageAdmin CMS网站建设实例:如何制作一个报名表? 有时我们根据需求需要制作一些自定义表,该如何去制作呢? 我们以制作一个报名表为例: 登录后台地址,进入后台, 2.在顶部导航中找到系统,并 ...

  10. JIT与JVM的三种执行模式:解释模式、编译模式、混合模式

    Java JIT(just in time)即时编译器是sun公司采用了hotspot虚拟机取代其开发的classic vm之后引入的一项技术,目的在于提高java程序的性能,改变人们“java比C/ ...