我有一组按钮,确定和取消如何自定义pyQT中的对话框信号/插槽?
buttonBox = QtGui.QDialogButtonBox(QtGui.QDialogButtonBox.Ok|
QtGui.QDialogButtonBox.Cancel)
我想要一个对话提示,当我们点击Cancel
self.connect(buttonBox, SIGNAL("rejected()"),
self, SLOT("reject()"))
def reject(self):
print 'hello'
self.emit(SIGNAL("reject()"))
我不知道发出什么。我不想只关闭这个东西。当我按X
时,我知道如何创建QMessageBox
。我想在reject
中做提示并关闭。
我希望它是有道理的。谢谢。
为了您的信息,当我按下X
关闭整个应用程序,我有一个覆盖方法
def closeEvent(self, event):
reply = QtGui.QMessageBox.question(self, 'Message', 'Are you sure to quit?', QtGui.QMessageBox.Yes | QtGui.QMessageBox.No, QtGui.QMessageBox.No)
if reply == QtGui.QMessageBox.Yes:
event.accept()
else:
event.ignore()
这种覆盖self.close()
方法。