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

Item view headers with stylesheets include space for sort indicator on all sections

    XMLWordPrintable

Details

    • 230ff021a (dev), 0af27bf83 (6.6), 18ffc07c8 (6.5)

    Description

      When working with stylesheets, in certain situations item view headers always leave space for a sort indicator. This leaves unnecessary blank space and/or strange looking early ellipsizing (if you are using that).

      This is a regression from Qt5, where sort indicator space was only removed from the text area for sections that were displaying a sort indicator. (Though there is an improvement from Qt5 in the same area: the space reserved for the sort indicator is much smaller, so the bug on Qt6 does not look as bad as it would have done.).

      This is also a difference to the other style classes I've used (QCommonStyle, QFusionStyle), which only reserve space in the sorted section.

      It seems to be connected to whether the section pseudo-element has a box set, and whether the up-arrow pseudo-element has a position set. The attached image and code samples link the stylesheet settings to the header layouts.

      To summarise the behaviour:

      1. section has border and arrow has position: sort indicator space is always reserved
      2. section has border, no arrow position: sort indicator space is never reserved, so indicator overlaps text, maybe a separate bug
      3. arrow has position, no section border specified: some space is always reserved, but I'm not sure if this is for the sort indicator as it appears smaller than in the first case
      4. no stylesheet, use fusion style: behaves as I would expect, space only reserved in the sorted section.

      On our Qt fork, a simple check on the style option in `QStyleSheetStyle::drawControl` seems to fix it, though it may also depend on the specific stylesheet our app uses.

      https://github.com/seequent/qtbase/commit/5fa87151096f52ae8596def970a5644f91fcc994

      Attachments

        1. CMakeLists.txt
          0.3 kB
        2. headers.png
          headers.png
          24 kB
        3. main.cpp
          1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            chehrlic Christian Ehrlicher
            arthurgw Arthur Gordon-Wright
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes