【发布时间】:2020-02-18 01:38:24
【问题描述】:
我有一组按钮,确定和取消
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() 方法。
【问题讨论】: