demo:直接重写 closeEvent 方法
def closeEvent(self, event):
print("老刘关闭的操作")
result=QMessageBox.question(self,"注意:","您真的要关闭窗体吗?",QMessageBox.Yes|QMessageBox.No,QMessageBox.No)
if result==QMessageBox.Yes:
event.accept()
else:
event.ignore()
QMessageBox.information(self,"消息","谢谢!")