1.在设计器中拖动QSlider到界面上,编辑滑块的qss样式,将Qt助手Qt Style Sheets Examples中QSlider样式代码粘贴到输入框:
QScrollBar:horizontal {
border: 2px solid green;
background: cyan;
height: 15px;
margin: 0px 40px 0 0px;
}
QScrollBar::handle:horizontal {
background: gray;
min-width: 20px;
}
2.要对QSlider的滑槽groove和把柄handle进行修改,对上面代码进行更改将滑块的槽和把柄换成图片,代码如下所示:
QSlider::groove:horizontal {
/*border: 1px solid #999999;*/
height:28px; /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */
/*background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4);*/
/*background-image: url(https://blog.csdn.net/:/images/sliderbackground.png);*//*注意:此属性会挤压handle图片导致高度不能调整*/
image: url(https://blog.csdn.net/:/images/sliderbackground.png);
margin: 2px 0;
}
QSlider::handle:horizontal {
/* background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);*/
image: url

3673

被折叠的 条评论
为什么被折叠?



