在qt designer中设计好两个窗口之后,在pycharm进行编译,生成两个py文件。
给主窗口的py文件导入:from “你的副窗口文件名” import “你的副窗口对象名”
在retranslateUi函数,你要按的按钮下添加: self.pushButton.clicked.connect(self.popWindow)
再写一个popwindow函数:
def popWindow(self):
self.form2 = QtWidgets.QWidget()
self.ui2 = Ui_Form()# Ui_form为你副窗口的对象名
self.ui2.setupUi(self.form2)
self.form2.show()
退出直接在按钮后加: self.pushButton.clicked.connect(QCoreApplication.instance().quit)
即可。