How to change the size of a QScrollBar's arrow

2019-08-06 16:52发布

Some time ago I posted this question trying to understand how could I change the size of a QScrollBar. I was able, at the end, to do what I wanted with the stylesheet code:

setStyleSheet("QScrollBar:vertical { width: 30px; };");

The problem is that, although the width of the scroll bar do change with the code above, the height of the up and down arrow widgets continues to be the same; they don't adjust automatically with the increase in width. So what I get now are two very flat up and down buttons in a large scroll bar.

Unfortunately I wasn't able to even "grasp" the arrow widgets, nor I know what would be the stylesheet code to control just them. The closest I got was from this SO question, but they don't apply to the vertical scroll bar.

So my question is: how can I change the size (particularly the height) of a (vertical) QScrollBar's arrow buttons? (note: no the arrow itself, but the normally square button that contains it)

1条回答
Emotional °昔
2楼-- · 2019-08-06 17:29

The Desktop theme specifies the height of these buttons. To have them scaling proportionally you have to remove the styling by setting a background color:

QScrollBar:vertical {
     width: 30px;
     background: red;
}

enter image description here

查看更多
登录 后发表回答