summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2024-02-28 14:46:54 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2024-02-29 15:35:57 +0100
commitf6d09a68f6fe7100bd1c6f6039db3832a9c5dce2 (patch)
treed61319eb133441c6f238ba89f8a27effdd840117
parent788ce268820ff8807aefa45293aa5f3ec299052f (diff)
QMessageBox: Forward helper checkbox state via lambda
There may not be a checkbox when the helper is initialized, and we want to support the case of a checkbox being added at a later stage. Regression from e5c40ec5c117376f401c01069f05780046d07094. Pick-to: 6.7 Change-Id: I397c3b3a101b249aab17804bd90085cfd4ab7dbb Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
-rw-r--r--src/widgets/dialogs/qmessagebox.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp
index e91a2625cf..9ff2b5159b 100644
--- a/src/widgets/dialogs/qmessagebox.cpp
+++ b/src/widgets/dialogs/qmessagebox.cpp
@@ -2782,9 +2782,14 @@ void QMessageBoxPrivate::initHelper(QPlatformDialogHelper *h)
auto *messageDialogHelper = static_cast<QPlatformMessageDialogHelper *>(h);
QObjectPrivate::connect(messageDialogHelper, &QPlatformMessageDialogHelper::clicked,
this, &QMessageBoxPrivate::helperClicked);
+ // Forward state via lambda, so that we can handle addition and removal
+ // of checkbox via setCheckBox() after initializing helper.
QObject::connect(messageDialogHelper, &QPlatformMessageDialogHelper::checkBoxStateChanged,
- checkbox, &QCheckBox::setCheckState);
-
+ q_ptr, [this](Qt::CheckState state) {
+ if (checkbox)
+ checkbox->setCheckState(state);
+ }
+ );
messageDialogHelper->setOptions(options);
}