帮我用qss写几个QSlider的样式
时间: 2024-03-27 20:37:32 浏览: 288
当然可以,以下是三个QSlider的样式代码,你可以根据自己的需要进行修改和使用。
1. 基本样式
```qss
QSlider {
background-color: transparent;
height: 20px;
}
QSlider::groove:horizontal {
border: 1px solid #bbb;
background: #ccc;
height: 3px;
border-radius: 2px;
}
QSlider::handle:horizontal {
background: #fff;
border: 1px solid #bbb;
width: 10px;
height: 10px;
margin: -4px 0;
border-radius: 5px;
}
```
2. 带刻度的样式
```qss
QSlider {
background-color: transparent;
height: 20px;
}
QSlider::groove:horizontal {
border: 1px solid #bbb;
background: #ccc;
height: 3px;
border-radius: 2px;
}
QSlider::handle:horizontal {
background: #fff;
border: 1px solid #bbb;
width: 10px;
height: 10px;
margin: -4px 0;
border-radius: 5px;
}
QSlider::sub-page:horizontal {
background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,
stop: 0 #bbb, stop: 1 white);
border: 1px solid #777;
height: 3px;
border-radius: 2px;
}
QSlider::add-page:horizontal {
background: #fff;
border: 1px solid #777;
height: 3px;
border-radius: 2px;
}
QSlider::handle:horizontal:hover {
background: #eee;
border: 1px solid #888;
}
QSlider::sub-page:horizontal:disabled {
background: #bbb;
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: 5px;
}
QSlider::groove:horizontal:disabled {
background: #eee;
border: 1px solid #aaa;
height: 3px;
border-radius: 2px;
}
QSlider::handle:horizontal:pressed {
background: #ccc;
border: 1px solid #444;
}
QSlider::tick-line:horizontal {
background: #bbb;
width: 1px;
height: 12px;
}
```
3. 垂直滑块样式
```qss
QSlider {
background-color: transparent;
width: 20px;
}
QSlider::groove:vertical {
border: 1px solid #bbb;
background: #ccc;
width: 3px;
border-radius: 2px;
}
QSlider::handle:vertical {
background: #fff;
border: 1px solid #bbb;
width: 10px;
height: 10px;
margin: 0 -4px;
border-radius: 5px;
}
QSlider::sub-page:vertical {
background: qlineargradient(x1: 0, y1: 1, x2: 0, y2: 0,
stop: 0 #bbb, stop: 1 white);
border: 1px solid #777;
width: 3px;
border-radius: 2px;
}
QSlider::add-page:vertical {
background: #fff;
border: 1px solid #777;
width: 3px;
border-radius: 2px;
}
QSlider::handle:vertical:hover {
background: #eee;
border: 1px solid #888;
}
QSlider::sub-page:vertical:disabled {
background: #bbb;
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: 5px;
}
QSlider::groove:vertical:disabled {
background: #eee;
border: 1px solid #aaa;
width: 3px;
border-radius: 2px;
}
QSlider::handle:vertical:pressed {
background: #ccc;
border: 1px solid #444;
}
QSlider::tick-line:vertical {
background: #bbb;
width: 12px;
height: 1px;
}
```
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![7z](https://img-home.csdnimg.cn/images/20241231044736.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)