Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.15.2
-
None
-
Windows 10
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.