From eb5f1837547ee25794586741b710a7b7c74f0e20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 1 Sep 2023 14:35:54 +0200 Subject: [PATCH] Add note to QMessageBox::button() about modifying returned button We don't have a good way to detect whether the button is modified or not, to bail out of using the native dialog helpers. Document that this API shouldn't be used to modify the standard buttons (they are standard after all), and recommend the explicit APIs for adding custom buttons instead. Fixes: QTBUG-112525 Change-Id: I38c8ef5e1717a85f0db59c9e705d0775982ffb57 Reviewed-by: Volker Hilsheimer (cherry picked from commit e9a1c53214d3936721e00bebbdc1e949e10658dd) Reviewed-by: Qt Cherry-pick Bot --- src/widgets/dialogs/qmessagebox.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 9067b913aa7..717d3675a07 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1007,6 +1007,12 @@ QMessageBox::StandardButton QMessageBox::standardButton(QAbstractButton *button) Returns a pointer corresponding to the standard button \a which, or \nullptr if the standard button doesn't exist in this message box. + \note Modifying the properties of the returned button may not be reflected + in native implementations of the message dialog. To customize dialog + buttons add a \l{addButton(QAbstractButton *button, QMessageBox::ButtonRole role)} + {custom button} or \l{addButton(const QString &text, QMessageBox::ButtonRole role)} + {button title} instead, or set the \l Option::DontUseNativeDialog option. + \sa standardButtons, standardButton() */ QAbstractButton *QMessageBox::button(StandardButton which) const