这是我的代码
主窗口
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(764, 719)
font = QtGui.QFont()
font.setKerning(False)
Form.setFont(font)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Form = QtWidgets.QDialog()
ui = Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())
子窗口
class Ui_Chat(object):
'''def __init__(self):
super().__init__()
self.setupUi(Chat)'''
def setupUi(self, Chat):
Chat.setObjectName("Chat")
Chat.resize(747, 711)
Chat.setStyleSheet()
self.back_button = QtWidgets.QPushButton(self.Chat_frame)
self.back_button.setGeometry(QtCore.QRect(0, 20, 51, 21))
self.back_button.setText("")
icon1 = QtGui.QIcon()
icon1.addPixmap(QtGui.QPixmap(":/images/Images/arrow395.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.back_button.setIcon(icon1)
self.back_button.setIconSize(QtCore.QSize(24, 24))
self.back_button.setCheckable(True)
self.back_button.setAutoExclusive(True)
self.back_button.setObjectName("back_button")
self.back_button.clicked.connect(self.mainscreen)
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Chat = QtWidgets.QDialog()
ui = Ui_Chat()
ui.setupUi(Chat)
Chat.show()
sys.exit(app.exec_())
派生类
from Dialer import Ui_Form
from chat import Ui_Chat
class DialerWindow(QtWidgets.QDialog,Ui_Form,Ui_Chat):
def __init__(self):
super().__init__()
self.setupUi(self)
self.show()
def mainscreen(self):
Form=QtWidgets.QDialog()
self.Dialer=Form
self.ui=Ui_Form()
self.ui.setupUi(Form)
self.Dialer.show()
这是我打开主窗口的代码,但我没有得到输出,这个代码是用派生类编写的,这个派生类继承了主窗口(Dialer)类和子窗口(chat)类的类属性,基本上我正在使用多重继承,所以我从子窗口调用此方法,该子窗口是此类的父级,因此我需要有关此问题的专业知识。