qt应用样式表时,右侧箭头消失为QScrollbar

时间:2017-08-29 12:19:20

标签: css qt qtstylesheets qscrollarea

我正在尝试为QScrollbar应用样式表,右侧箭头没有显示,我无法更改句柄宽度和栏的背景颜色。

可以帮助我制作右箭头并改变手柄的宽度和背景颜色吗?

代码:

sliderOne.setStyleSheet("QScrollBar:horizontal {border: 1px solid none;height:15px;margin:0px 20px 0px 20px;} QScrollbar::handle:horizontal {min-width:8px;}");

图片:即将到来

enter image description here

1 个答案:

答案 0 :(得分:0)

我使用自定义图片达到了我的要求,感兴趣的人可以查看此代码。

sliderOne.setStyleSheet("QScrollBar:horizontal {border: 2px solid grey;background: none;height: 15px;margin: 0px 20px 0 20px;} QScrollBar::handle:horizontal {background: gray;min-width: 10px;} QScrollBar::add-line:horizontal {border: 2px solid grey;background: none;width: 20px;subcontrol-position: right;subcontrol-origin: margin;} QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {background: none;} QScrollBar::right-arrow:horizontal {image: url(path/arrow-right-down.png);background: none;} QScrollBar::right-arrow:horizontal:pressed { image: url(path/arrow-right-up.png);background: none;} QScrollBar:left-arrow:horizontal {image: url(path/arrow-left-down.png);background: none;} QScrollBar:left-arrow:horizontal:pressed {image: url(path/arrow-left-up.png);background: none;} QScrollBar::sub-line:horizontal {border: 2px solid grey;background: none;width: 20px;subcontrol-position: left;subcontrol-origin: margin;}");