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

Wrong size of a viewport of QGraphicsView with scrollbars configured in QSS

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.2
    • Fix Version/s: None
    • Component/s: Widgets: GraphicsView
    • Labels:
      None
    • Environment:
      Windows 10
    • Platform/s:
      Windows

      Description

      The issue appeares when size of scrollbars is controlled by qss. For example:

       

      QScrollBar:horizontal { height: 5px; }
      QScrollBar:vertical { width: 5px; }
      

      The size of availabe area to show a scene should be decreased by these values when scroll bars are visible. But that doesn't happen. Scroll bars by themself look smaller according to style.

       

      Here is how it looks without stylesheet with scroll bars at maximum value where red line is border of the scene:

      And here us with stylesheets. Here you can see gap between red line and scroll bars.

      I checked code of QGraphicsView relateted classes and think that problem is in QGraphicsViewPrivate::recalculateContentSize()

      The size needed for scrollbars is returned from objects style

      int scrollBarExtent = q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, nullptr, q);
      

      I see next problems in this code:

      • q here is pointer to QGraphicsView. Probably pyxelMetric need to be called with pointer to particular scroll bar;
      • options parameter is not used for pixelMetric. Probably options need to be used here and initialilzed for each scroll bar;
      • the value is the same for horizontal and vertical scroll bars. But it's possible that developer would like to have scroll bars with different size.

      Test project reproducing the bug is attached. MainWindow.cpp file contains commented macro

      //#define WITH_SCROLLBAR_STYLESHEET
      

      Uncomment it to see the bug in application.

        Attachments

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

          Activity

            People

            Assignee:
            bibr Andreas Aardal Hanssen
            Reporter:
            medyakovvit Vitaly
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes