PDA

View Full Version : QSlider custom handle image not displayed



planglois
29th July 2008, 22:48
Hi,

I'm trying set a custom image for a QSlider handle. I am able to see the handle in designer but when I build the application, the handle is not shown. The resource file seems ok because I can show all pixmap in a QLabel...

Vertical Slider Style Sheet


QSlider::groove:vertical {
border: 1px solid #999999;
width: 4px;
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4);
margin-top: 2px;
margin-bottom: 2px;
}
QSlider::handle:vertical {
image: url(:/GenericWidget/Ressources/vcursor.png) 1;
height: 14px;
margin-left: -6px;
margin-right: -6px;
}


Horizontal Slider Style Sheet:


QSlider::groove:horizontal {
border: 1px solid #999999;
height: 4px;
background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #B1B1B1, stop:1 #c4c4c4);
margin-left: 2px;
margin-right: 2px;
}
QSlider::handle:horizontal {
image: url(:/GenericWidget/Ressources/hcursor.png);
width: 14px;
margin-top: -6px;
margin-bottom: -6px;
}


In Designer:
http://www.qtcentre.org/forum/attachment.php?attachmentid=2409&stc=1&d=1217364367

In the application:
http://www.qtcentre.org/forum/attachment.php?attachmentid=2410&stc=1&d=1217364367

planglois
5th September 2008, 14:49
The solution for me was not to use designer and set the style sheet directly in the code with the method setStyleSheet...