Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.5.3
-
None
-
b30121041 (dev), 8a8481f7e (6.7), 4266bf601 (6.6), f5de35783 (tqtc/lts-6.5)
Description
This issue is being transferred from https://bugreports.qt.io/browse/PYSIDE-2490
It occurred with Qt 6.5.3. I tried to make a minimal C++ example to reproduce the issue, but the issue did not occur for my C++ example (perhaps because I was using a different version of Qt - 6.2.4, which I can install on Ubuntu without compiling Qt). That example is attached.
Pasted below is my original message (the issue occurred on multiple operating systems):
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()
Attachments
Issue Links
- relates to
-
QTBUG-6018 QDialog as a delegate woes
-
- Closed
-
-
PYSIDE-2490 Rejected QMessageBox emits Accepted Signal
-
- Closed
-
For Gerrit Dashboard: QTBUG-118226 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
543986,4 | QMessageBox: Respect explicit accept/reject after closing dialog | dev | qt/qtbase | Status: MERGED | +2 | 0 |
547867,2 | QMessageBox: Respect explicit accept/reject after closing dialog | 6.7 | qt/qtbase | Status: MERGED | +2 | 0 |
548007,2 | QMessageBox: Respect explicit accept/reject after closing dialog | 6.6 | qt/qtbase | Status: MERGED | +2 | 0 |
548079,2 | QMessageBox: Respect explicit accept/reject after closing dialog | tqtc/lts-6.5 | qt/tqtc-qtbase | Status: MERGED | +2 | 0 |