如何检查以下QMessageBox中的哪个按钮被单击? button == QMessageBox.Ok
无法正常工作。
class WarningWindow(QMessageBox):
nextWindowSignal = pyqtSignal()
def __init__(self):
super().__init__()
self.setWindowTitle('A title')
self.setText("Generic text")
self.setStandardButtons(QMessageBox.Ok | QMessageBox.Cancel)
self.buttonClicked.connect(self.nextWindow)
def nextWindow(self,button):
if button == QMessageBox.Ok:
print('ok')
elif button == QMessageBox.Cancel:
print('cancel')
else:
print('other)
self.nextWindowSignal.emit()