Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-127988

Stylesheets affect QMessageBox without Options.DontUseNativeDialog

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.7.1, 6.7.2, 6.7.3
    • Widgets: Style Sheets
    • None
    • macOS

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

       

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            rkoecher Rene Koecher
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes