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

QToolBar Extension button has fixed size when styled with QSS

    XMLWordPrintable

Details

    • Windows

    Description

      The QToolBar extension button inherits styling from QToolButton. When said styling affects the size of those buttons, it is not taken into account for the extension button.


      In the above exaggerated example, I have applied the following styling to QToolButtons:

      QToolBar QToolButton {
          background: red;
          border: 1px solid yellow;
          margin: 0;
          padding: 0;
          width: 32px;
          height: 32px;
          max-width: 32px;
          max-height: 32px;
      }
      

      Despite the large size of the buttons here, the extension button is mostly cutoff due to being a fixed width of 12px. Applying a negative margin-left to the extension button cuts off the left side and reveals the center of it, where the icon can then be seen.

      My naive understanding is that this is due to QStyleSheetStyle::pixelMetric() having no handling for PM_ToolBarExtensionExtent

          case PM_ToolBarExtensionExtent:
              break;
      

      Thus it resolves to the value set in QCommonStyle::pixelMetric()

          case PM_MenuButtonIndicator:
              ret = int(QStyleHelper::dpiScaled(12, opt));
              break;
      

      Expected Behaviour

      The extension button is styled like the other QToolButtons and given the correct amount of space in the toolbar.


      Extension button visible


      Extension button not needed

      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
            warchamp7 Taylor Giampaolo
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes