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

Mac: Focus rectangle isn't rendered when a style sheet is set

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.3.1
    • Widgets: Styles
    • None
    • macOS

    Description

      Steps to reproduce

      1. Compile and run the attached example on Mac (see some instructions I followed in README.txt)
      2. You'll see a widget containing two line edit fields: one line edit has a (minimalistic) style sheet attached, the other one has not.
      3. Switch focus between the line edits, e.g. by tabbing.
      4. EXPECTED: Both line edits show the focus rectangle.
      5. ACTUAL: The line edit with style sheet doesn't show the focus rectangle, while the other line edit does.

      Explanation

      When a widget, like QLineEdit, has focus on macOS it is standard that a focus rectangle is drawn around its borders. By default this is the case in Qt. However when a style sheet is set on the widget (or on one of its ancestors), this functionality is broken.
      See the "steps to reproduce".

      I believe that this is a regression caused by QTBUG-93032.
      Indeed, this focus rectangle can be controlled via the WA_MacShowFocusRect attribute.
      In the case that a style sheet is set the code added in QTBUG-93032 is reached, which sets this attribute to false.

      On Windows the "focus rectangle" works fine, but this is of course not implemented via the WA_MacShowFocusRect attribute.

      Workaround?

      Note that simply forcing the WA_MacShowFocusRect to true isn't a valid workaround I think, since the QStyleSheetStyle::polish() code might be called after certain (polish) events. And the WA_MacShowFocusRect attribute is something you want to set only once at creation time. Ideally we never have to set it, since we want to rely on the recommended default behavior for macOS.

      Attachments

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

        Activity

          People

            tpochep Timur Pocheptsov
            catsareqt551 Willem Peerlinck
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes