使用的是pyside6,代码如下:
app = QApplication([])
dialog = QDialog()
layout = QVBoxLayout()
button_accept = QPushButton("Accept")
button_reject = QPushButton("Reject")
layout.addWidget(button_accept)
layout.addWidget(button_reject)
dialog.setLayout(layout)
# 连接接受和拒绝按钮的信号与槽
button_accept.clicked.connect(dialog.accept)
button_reject.clicked.connect(dialog.reject)
dialog.setWindowModality(Qt.ApplicationModal)
# 显示对话框并等待其关闭
result = dialog.exec()
if result == QDialog.Accepted:
print("Dialog was accepted.")
else:
print("Dialog was rejected.")
app.exec()
点击按钮后进程不自动结束,必须手动杀进程,这是为什么?要怎么修改?