我有一个qdialog在我使用exec时运行并运行但是当我使用call回调取消按钮时,我无法取消对话框。
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName(_fromUtf8("MainWindow"))
MainWindow.resize(1200, 900)
self.StudentButton_Add = QtGui.QPushButton(MainWindow)
self.StudentButton_Add.setGeometry(QtCore.QRect(30, 830, 91, 23))
self.StudentButton_Add.setObjectName(_fromUtf8("StudentButton_Add"))
self.StudentButton_Add.clicked.connect(self.addStudentfunc)
def retranslateUi(self, MainWindow):
self.StudentButton_Add.setText(_translate("MainWindow", "Add Student", None))
def addStudentfunc(self):
#function to execute dialog
self.homewindow = QtGui.QDialog()
self.ui = Ui_DialogAdd()
self.ui.setupUi(self.homewindow)
self.homewindow.exec_() #this is where i have used exec
class Ui_DialogAdd(object):
def setupUi(self, Dialog):
Dialog.setObjectName(_fromUtf8("Dialog"))
Dialog.resize(480, 640)
self.pushButton_2 = QtGui.QPushButton(Dialog)
self.pushButton_2.setGeometry(QtCore.QRect(140, 530, 61, 27))
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2"))
self.pushButton_2.clicked.connect(self.cancelClicked)
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def canelClicked(self):
Ui_dialogAdd.close() #this is where I am trying to close the dialog