I am trying to get rid of the arrows of a vertical QScrollBar as part of a QListWidget by applying a stylesheet using Qt 5.15.
As I don't want weird behavior at the top and bottom, simply hiding the arrows as suggested here is insufficient. One answer to this question suggests to set the width
and height
of the arrows to 0px
, which I tried using
setStyleSheet("QScrollBar:vertical::up-arrow, QScrollBar:vertical::down-arrow {height: 0px;}");
but this results in the scrollbar not showing up. Forcing it to show up by using
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
on the QListWidget results in the standard scrollbar to show up.
Interestingly enough, using any non-zero height, e.g. 30px
leads to the same results while changing the width works perfectly fine (although the width is then applied to the whole scrollbar but that is beside the point).
How can I achieve this without rewriting all mouseEvents?
musicamante said:
Based on that I found out that I had the wrong idea about add-line and sub-line as well as the arrows.
The following code managed to hide the arrows:
Setting the width of
QScrollBar:vertical
is optional but changing the background color appears to be required.