http://blog.csdn.net/Angelasan/article/details/44917283
发现我的使用时候有点跟他不同.
我是
g: utf-8 -*-# Form implementation generated from reading ui file '1.ui'## Created by: PyQt5 UI code generator 5.6## WARNING! All changes made in this file will be lost!from PyQt5 import QtCore, QtGui, QtWidgetsfrom PyQt5.QtCore import *from PyQt5.QtWidgets import * class Ui_Dialog(object): def setupUi(self, Dialog): Dialog.setObjectName("Dialog") Dialog.resize(813, 703) self.textEdit = QtWidgets.QTextEdit(Dialog) self.textEdit.setGeometry(QtCore.QRect(80, 120, 671, 421)) self.textEdit.setObjectName("textEdit") self.retranslateUi(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog) Dialog.show() def retranslateUi(self, Dialog): _translate = QtCore.QCoreApplication.translate Dialog.setWindowTitle(_translate("Dialog", "Dialog"))if __name__ == "__main__": import sys app = QApplication(sys.argv) widget = QWidget(None) Ui_Dialog().setupUi(widget) sys.exit(app.exec_()) pass
也就是第五步从1.py进行修改:1.在setupUi里面最后一行写的是Dialog.show() 2.最后贴上
if __name__ == "__main__": import sys app = QApplication(sys.argv) widget = QWidget(None) Ui_Dialog().setupUi(widget) sys.exit(app.exec_()) pass
就可以了.
原因就是qtdesingner不给写这个class的show,也缺少if main这些东西,然后实例化的时候需要自己看着改,我这里的class是
Ui_Dialog.所以倒数第三行是他加()