Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFontDialog on macOS 27 isn't modal anymore
Qt 6.12 LTS is out! See what's new in the release blog

QFontDialog on macOS 27 isn't modal anymore

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 5 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    barbicels
    wrote last edited by
    #1

    The documentation for QFontDialog in Qt Widgets 6.12 says that it operates the dialog modally.

    In macOS 27, the (OS-native) font dialog lost its OK and Cancel buttons, so it's sort of non-modal now. Our code (compiled in Qt 6.10.3) continues to block on the QFontDialog::getFont call as it did in macOS 26 and earlier when the dialog was fully modal, so the user must close the font dialog to continue, and the ok value on return is always false.

    I understand that there is a currentFontChanged signal we could use, and there's also the DontUseNativeDialog option to use the Qt (non-OS-native) font dialog instead, but it looks to me like QFontDialog is now behind the times with respect to macOS, so the Qt API or at least its documentation needs an update.

    e59d7b71-7602-4385-a381-43564b8acbf6-image.png

    1 Reply Last reply
    1
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote last edited by
      #2

      Hi,

      Can you provide a minimal compilable example that shows this behaviour change ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • I Offline
        I Offline
        IgKh
        wrote last edited by IgKh
        #3

        @barbicels Qt's implementation makes some assumptions about the internal structure of NSFontPanel (AppKit's native font selector) to inject the action buttons into it. They are not a built-in option. This likely broke with macOS changes. I don't see an open ticket in the bug tracker about it - I encourage you to create one, with the minimal reproducer.

        1 Reply Last reply
        1
        • B Offline
          B Offline
          barbicels
          wrote last edited by barbicels
          #4

          Minimal compilable example, based on Qt Creator's "Qt Widgets Application":

          #include "mainwindow.h"
          #include <QtWidgets/QFontDialog>
          
          MainWindow::MainWindow(QWidget *parent)
              : QMainWindow(parent)
          {
              bool ok = false;
              QFont font = QFontDialog::getFont(&ok, this);
              qDebug() << "ok =" << ok << "font =" << font;
          }
          
          MainWindow::~MainWindow() = default;
          

          Result under macOS 27, regardless of what font is selected in the Apple font dialog, after closing the dialog using the red button:

          ok = false font = QFont(.AppleSystemUIFont,13,-1,5,400,0,0,0,0,0,0,0,0,0,0,1)
          

          In macOS 26, this same code would have set ok to true and font to whatever was selected, after the user clicked the OK button that is no longer visible in macOS 27 (as the other commenter described).

          1 Reply Last reply
          1
          • I Offline
            I Offline
            IgKh
            wrote last edited by
            #5

            Indeed. I filed https://qt-project.atlassian.net/browse/QTBUG-151608 on the matter.

            1 Reply Last reply
            4
            • JonBJ JonB referenced this topic
            • AndyBriceA Offline
              AndyBriceA Offline
              AndyBrice
              wrote last edited by
              #6

              I am using this as a replacement for QFontDialog::getFont(), for now:

              QFont getFontFromDialog( bool* ok, const QFont& font, QWidget* parent )
              {
                  Q_ASSERT( ok );
                  QFontDialog::FontDialogOptions options;
              #ifdef Q_OS_MACOS
                  if ( QOperatingSystemVersion::current() >= QOperatingSystemVersion( QOperatingSystemVersion::MacOS, 27 ) )
                  {
                      // native font dialog does not work with Qt for macOS 27
                      options |= QFontDialog::DontUseNativeDialog;
                  }
              #endif
                  QFont f = QFontDialog::getFont( ok, font, parent, QString(), options );
                  return f;
              }
              

              But I hope we get a fix so that we can use the new macOS 27 native font menu.

              1 Reply Last reply
              0
              • T Offline
                T Offline
                TowMichal14
                Banned
                wrote last edited by TowMichal14
                #7

                Classic macOS breaking platform consistency again. We ran into the exact same issue after updating our build machines — calling the static QFontDialog::getFont basically turns into a dead end because the native panel now behaves more like an inspector rather than a traditional modal dialog. Setting the QFontDialog::DontUseNativeDialog flag is pretty much the only sane workaround right now if you rely on blocking modal flow with OK/Cancel, even though the Qt-rendered dialog looks noticeably out of place on newer macOS versions.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt
                • Unsolved