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>
This commit is contained in:
Tor Arne Vestbø 2024-02-28 14:46:54 +01:00
parent 788ce26882
commit f6d09a68f6

View File

@ -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);
}