Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.7.1, 6.7.2, 6.7.3
-
None
Description
As of Qt 6.6 but going through all 6.7.* versions a QMessageBox on macOS will not display a native Cocoa message box if the message box would be affected by a stylesheet, completely ignoring Options.DontUseNativeDialog.
This effectively removes the ability to have an application-wide stylesheet while still using the native macOS Cocoa message boxes as anything that would in theory affect QMessageBox - like a font or border setting on QWidget - will force a non-native QMessageBox.
It also clashes with the behaviour of QFileDialog which still defaults to a Cocoa dialog regardless if it would be affected by an application-wide stylesheet (it behaves as expected and actually respects the Option.DontUseNativeDialog / the absence of that option).
The source of the problem seems to in qmessagebox.cpp / QMessageBoxPrivate::canBeNative(): https://github.com/qt/qtbase/blob/4ed994487484b37ff960144806445f8f9ce42286/src/widgets/dialogs/qmessagebox.cpp#L2854
The current check will force a non-native dialog whenever a stylesheet is present, regardless if either of the two DontUseNativeDialogs options is present:
if (QCoreApplication::testAttribute(Qt::AA_DontUseNativeDialogs) || q->testAttribute(Qt::WA_DontShowOnScreen) || q->testAttribute(Qt::WA_StyleSheet) || (options->options() & QMessageDialogOptions::Option::DontUseNativeDialog)) { return false; }