一个漂亮的滑动条样式

前段时间做一个东西,要用到滑动条,在更改样式时破费脑筋!因为总有一些问题:例如,当你滑动滑块到两端时,下面的滑槽总是遮不住,还有一个就是你要滑到两端时,你设置的弧度圆角突然变成方的,细细很不美观。
两端露出
方的情形就不展示了。
未滑动时
滑动到末端
主要调整的是border-radius这个属性,其次是margin属性。
下面附上样式源码:

slider_Time->setStyleSheet(
                //滑条
                "QSlider::groove:horizontal{"
                " border: 1px solid #999999;"
                " height: 5px; "

                "position: absolute;"
                "border-radius :3px;"
                " background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4);"
                " margin: 1px 0;"
                " left: 3px; right: 3px;"
                "}"
                //小滑块
                "QSlider::handle:horizontal {"   
                " background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);"
               "border: 1px solid #5c5c5c;
                "width: 12px;"
                " height: 12px; "
                "margin: -2px -1; "/* handle is placed by default on the contents rect of the groove. Expand outside the groove */
                "  border-radius: 4px;"
                "}"
                //滑块滑过改变样式
                " QSlider::add-page:horizontal {"
                "border-radius :2px;"
                " margin: 1px 1;"
                "background: white;"
                //  "position: absolute;"
                //  " left: 2px; right: 2px;"
                "}"
                "QSlider::sub-page:horizontal {"
                "border-radius :2px;"
                " margin: 1px 1;"//
                "  background-color:#86dfc6;"
                // "position: absolute;"
                // " left: 2px; right: 2px;"
                "}"
                );
  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值