Details
-
Bug
-
Resolution: Out of scope
-
Not Evaluated
-
None
-
6.5.3
-
None
Description
If a QMessageBox is accepted by the user clicking a button, and then later "reject()" is called programmatically on the message box, the QMessageBox emits the "accepted()" signal instead of the "rejected()" signal.
In PySide2, this did not occur. This is new to PySide6.
Some sample code is pasted below. Note that when you click "Yes", "reject()" is called via QTimer, but it still emits "accepted()" instead of "rejected()".
from PySide6.QtCore import QTimer from PySide6.QtWidgets import QApplication, QMessageBox app = QApplication() msg = 'Press "Yes"' standard_buttons = QMessageBox.StandardButton buttons = standard_buttons.Yes | standard_buttons.No box = QMessageBox(QMessageBox.Question, 'Question', msg, buttons) def accepted(): print('Accepted!') # Now we will reject it later print('Now rejecting...') QTimer.singleShot(0, box.reject) def rejected(): print('Rejected!') def finished(): print('Finished!') box.finished.connect(finished) box.accepted.connect(accepted) box.rejected.connect(rejected) box.show() app.exec()
Python 3.10.12 Qt 6.6.1 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 11.4.0) [Python limited API 3.10.12] Accepted #0 Now rejecting... Finished #0! Accepted #1 Finished #1!
Python 3.10.12 Qt 5.15.14 (x86_64-little_endian-lp64 shared (dynamic) debug build; by GCC 11.3.0) Accepted #0 Now rejecting... Finished #0! Rejected #0! Finished #1!
Attachments
Issue Links
- relates to
-
QTBUG-118226 Rejected QMessageBox emits Accepted Signal
- Closed