如何更改QScrollBar箭头的大小? [英] How to change the size of a QScrollBar's arrows?

查看:476
本文介绍了如何更改QScrollBar箭头的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

前段时间,我发布了这个问题试图了解如何更改QScrollBar的大小.最后,我可以使用样式表代码执行我想要的操作:

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.

不幸的是,我什至无法抓住"箭头小部件,我也不知道控制它们的样式表代码是什么.我得到的最接近的是这个SO问题,但是它们不适用于垂直滚动条.

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.

所以我的问题是:如何更改(垂直)QScrollBar箭头按钮的大小(尤其是高度)? (注意:没有箭头本身,但是包含箭头的通常是正方形的按钮)

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)

推荐答案

桌面"主题指定这些按钮的高度.要使它们成比例缩放,您必须通过设置背景色来删除样式:

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;
}

这篇关于如何更改QScrollBar箭头的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆