Inconsistent look of QScrollBar on Windows
-
I have a custom scroller which looks fine on Mac, but on Windows it has a strange gray background.
Here is a photo of the custom vertical scroller. The horizontal scroller is the default scroller, just for comparison:
Here is how it looks on Mac:
Here is my code for the custom scroller. Am I missing something in my stylesheet?// in the MainWindow: setStyleSheet( "QScrollBar:vertical { \ background:rgb(42, 42, 42); \ border-top-right-radius:2px; \ border-bottom-right-radius:2px; \ width:16px;\ margin:0px;\ }\ QScrollBar::handle:vertical { \ background-color:rgb(66, 66, 66); \ border-radius:4px; \ min-height:20px; \ margin:2px 4px 2px 4px;\ }\ QScrollBar::handle:vertical:hover, QScrollBar::handle:horizontal:hover{ \ background-color:rgb(42, 130, 218);\ }\ QScrollBar::add-line:vertical{ \ background:none;\ height:0px;\ subcontrol-position:right;\ subcontrol-origin:margin;\ }\ QScrollBar::sub-line:vertical {\ background:none;\ height:0px;\ subcontrol-position:left;\ subcontrol-origin:margin;\ }\ QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal {\ border: 2px solid grey;\ width: 3px;\ height: 3px;\ background: white;\ });
-
Turns out that I needed to add also the arrow and page definition on Windows. For example:
QScrollBar:left-arrow:vertical, QScrollBar::right-arrow:vertical {
border: 2px solid grey;
width: 3px;
height: 3px;
background: white;
}QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
background: none;
}
This fixed my original issue, but the arrows aren't visible (which doesn't matter in my case, but it's just weird that they don't show up).