帮我用qss写几个QSlider的样式
时间: 2024-03-27 13:37:32 浏览: 233
Qt例程源代码QSlider.7z
5星 · 资源好评率100%
当然可以,以下是三个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;
}
```
阅读全文