Why does changing the stylesheet of horizontal QScrollBar make vertical QScrollbar appear?
-
I have a QScrollArea(we'll call scroll area 1) that has only vertical scrolling enabled, and within that scroll area, I have another QScrollArea(we'll call scroll area 2) that has only horizontal scrolling enabled. Right now, I have the scroll area 1 small enough that no scrolling is necessary, so the vertical scroll bar doesn't appear. However, for some reason, changing one small thing on the stylesheet for the horizontal QScrollBars will make the vertical scroll bar appear in scroll area 1.
Here is a screenshot before making any stylesheet changes whatsoever to QScrollBar:
And then after simply adding
QScrollBar::handle:hover:horizontal { background: #016894; }
to the .qss file, the scrollbar on the right can now be seen:
Note that the scroll arrows are also gone, but that's a more intuitive result of me only changing one subcontrol, state, and property. Because I did see in the docs(https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qscrollbar) that "if one property or sub-control is customized, all the other properties or sub-controls must be customized as well.".
So I could see how messing with part of QScrollBar style, but not all of it, could ruin other parts of the QScrollBar style. But I'm not sure why it would affect whether or not a scroll bar is hidden? The thing is, I know how to add the arrows back in, but I don't know what about the style causes that vertical scroll bar to suddenly appear; I don't know how to get rid of it by adjusting the stylesheet.
Thanks.
-
Hi @AAhusk,
QScrollBar::handle:hover:horizontal
I believe it should be:
QScrollbar::handle:horizontal:hover
ie
horizontal
before thehover
?Cheers.
-
Hi @AAhusk,
QScrollBar::handle:hover:horizontal
I believe it should be:
QScrollbar::handle:horizontal:hover
ie
horizontal
before thehover
?Cheers.
@Paul-Colby After testing, it doesn't seem to make a difference what order
horizontal
andhover
are in. -
Well, if the documentation already says that you might need to modify all properties (as you have mentioned), then this certainly also includes the height of the scroll bar. It might be ever so slightly higher than before which would force the vertical scroll bar to show.