QSlider 的样式设置

转载自:http://blog.csdn.net/robertkun/article/details/20119135


这里写图片描述

设计漂亮的style sheet,注意背景色..否则每个角上会有一个像素的小点..

QSlider::groove:horizontal
{
    height: 5px;
    background: #C0C0C0;
    border: 1px solid #4A708B;
    border-radius: 1px;
    padding-left:-1px;
    padding-right:-1px;
}

// 已经划过的地方
QSlider::sub-page:horizontal
{
    height: 10px;
    background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4);
    background: qlineargradient(x1:0, y1:0.2, x2:1, y2:1, stop:0 #5DCCFF, stop:1 #1874CD);
    border: 1px solid #4A708B;
    border-radius: 2px;
}

// 还没划过的地方
QSlider::add-page:horizontal
{
    height: 10px;
    background: #575757;
    border: 0px solid #777;
    border-radius: 2px;
}

// 设置滑动键
QSlider::handle:horizontal 
{
    width: 11px;
    background: qradialgradient
    (
        spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, 
        stop:0.6 #45ADED, stop:0.778409 rgba(255, 255, 255, 255)
    );
    margin-top: -3px;
    margin-bottom: -3px;
    border-radius: 5px;
}

// 滑动键鼠标悬停
QSlider::handle:horizontal:hover
{
    width: 11px;
    background: qradialgradient
    (
        spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, 
        stop:0.6 #2A8BDA, stop:0.778409 rgba(255, 255, 255, 255)
    );
    margin-top: -3px;
    margin-bottom: -3px;
    border-radius: 5px;
}

QSlider::sub-page:horizontal:disabled
{
    background: #00009C;
    border-color: #999;
}

QSlider::add-page:horizontal:disabled
{
    background: #eee;
    border-color: #999;
}

QSlider::handle:horizontal:disabled
{
    background: #eee;
    border: 1px solid #aaa;
    border-radius: 4px;
}

以下是竖版的样式:
这里写图片描述


QSlider::groove:vertical
{
    width: 5px;
    background: #C0C0C0;
    border: 1px solid #4A708B;
    border-radius: 1px;
    padding-left:-1px;
    padding-right:-1px;
    padding-top:-1px;
    padding-bottom:-1px;
}

QSlider::sub-page:vertical
{
    background: #575757;
    border: 1px solid #4A708B;
    border-radius: 2px;
}

QSlider::add-page:vertical
{
    width: 10px;
    background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #c4c4c4, stop:1 #B1B1B1);
    background: qlineargradient(x1:0, y1:0.2, x2:1, y2:1, stop:0 #5DCCFF, stop: 1 #1874CD);
    border: 0px solid #777;
    border-radius: 2px;
}

QSlider::handle:vertical 
{
    height: 11px;
    background: qradialgradient
    (
        spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, 
        stop:0.6 #45ADED, stop:0.778409 rgba(255, 255, 255, 255)
    );
    margin-left: -3px;
    margin-right: -3px;
    border-radius: 5px;
}

QSlider::handle:vertical:hover
{  
    height: 11px;
    background: qradialgradient
    (
        spread:pad, cx:0.5, cy:0.5, radius:0.5, fx:0.5, fy:0.5, 
        stop:0.6 #2A8BDA, stop:0.778409 rgba(255, 255, 255, 255)
    ); 
    margin-left: -3px;
    margin-right: -3px;
    border-radius: 5px;
}

QSlider::sub-page:vertical:disabled
{
    background: #00009C;
    border-color: #999;
}

QSlider::add-page:vertical:disabled
{
    background: #eee;
    border-color: #999;
}

QSlider::handle:vertical:disabled
{
    background: #eee;
    border: 1px solid #aaa;
    border-radius: 4px;
}
  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值