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

[REG.]Widgets lose their focus frame when QProxyStyle is set

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.4.3, 6.5.0
    • 6.4.0, 6.4.1
    • Widgets: Styles
    • None
    • macOS
    • 3bb055d8a (dev), 9af5ed3a8 (6.4), ffe98c9b5 (6.5)

    Description

      If a QProxyStyle (or derived class) is set on QApplication, some widgets (QPushButton, QCheckBox) no longer have a focus frame when they are focused (on macOS).

      With Qt 6.3.2, or if the style is directly set on the widget everything is ok.

      I guess the problem was introduced with this commit:

      https://code.qt.io/cgit/qt/qtbase.git/commit/?id=5d8a7652b995124495ef4f4a43fd8cf461367d62

       

      int main(int argc, char *argv[])
      {
          QApplication a(argc, argv);
      
          // as soon as QProxyStyle (or derived class) is set on QApplication
          // some widgets no longer have a focus ring
          a.setStyle(new QProxyStyle);
      
          QWidget *w = new QWidget;
          w->setLayout(new QHBoxLayout(w));
          w->layout()->addWidget(new QPushButton("PushButton", w));
          w->layout()->addWidget(new QCheckBox("CheckBox", w));
          w->show();
      
          return a.exec();
      }
      

       

      Important note:

      Keyboard navigation is disabled on macOS by default. You have to enable it, otherwise buttons won't get focused at all when pressing TAB.

      macOS 13: System Settings -> Keyboard -> Keyboard navigation

      macOS <=12: System Settings -> Keyboard -> Shortcuts -> Use keyboard navigation to move focus...

      Attachments

        1. CMakeLists.txt
          0.2 kB
        2. main.cpp
          0.6 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            peppe Giuseppe D'Angelo
            jgrill Joachim Grill
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes