How to hide QScrollBar
arrows?
I need to hide in horizontal scrollbar.
I was trying to hide with setStyleSheet
:
setStyleSheet(" QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal { height:0px; }" )
but it doesn't work.
To hide the scrollbar and disable scrolling, we can use the CSS overflow property. This property determines what to do with content that extends beyond the boundaries of its container. To prevent scrolling with this property, just apply the rule overflow: hidden to the body (for the entire page) or a container element.
Scrollbar Selectors For webkit browsers, you can use the following pseudo elements to customize the browser's scrollbar: ::-webkit-scrollbar the scrollbar. ::-webkit-scrollbar-button the buttons on the scrollbar (arrows pointing upwards and downwards). ::-webkit-scrollbar-thumb the draggable scrolling handle.
Disabling scroll with only CSS. There's another way to disable scrolling that is commonly used when opening modals or scrollable floating elements. And it is simply by adding the CSS property overflow: hidden; on the element you want to prevent the scroll.
Create a QScrollBar
and assign it this stylesheet and this should do the trick. See example below.
QScrollBar:vertical {
width: 15px;
background: #f1f1f1;
}
QScrollBar::handle:vertical {
background: #888;
}
QScrollBar::add-line:vertical {
border: 2px solid gray;
background: #f1f1f1;
}
QScrollBar::sub-line:horizontal {
border: 2px solid gray;
background: #f1f1f1;
}
QScrollBar::handle:hover:vertical {
background: #555;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With