Reputation: 25
Whenever I set the groove of my QSlider to an image (as an image or background-image) or background-color (but not color) I am unable to drag it, but only move it by clicking on the slider to step it. Here is my current stylesheet for reference, this is being set via a call to setStyleSheet()
fanSliderOnStyleSheet = "QSlider {padding-left: 80px; padding-right: 80px;} \n"
"QSlider::handle:horizontal{image: url(:/images/FanSlider/blowerSw2.png); padding:-65px; }\n"
"QSlider::groove:horizontal{background-image: url(:/images/FanSlider/barind.png);}\n";
If i comment out the line that sets the groove the slider works as intended so I've eliminated any other variables of the slider I can think of.
Note: I prefer setting it as a background-image over image as it maintains the true size if I do it this way.
Does anyone have any idea on how to fix this, or is it by chance a bug with Qt? I've been banging my head against the wall on this for the past couple days and my searches haven't revealed any useful information.
Upvotes: 0
Views: 404
Reputation: 6584
The padding is too high for your handle: if you set a value higher than the size of the image in the groove property, it will interfere with the handler movements (the grab section would be empty).
I get exactly the same problem when I set an image with a width to 100px and a padding property to 110px.
Remove the padding and it should be OK:
fanSliderOnStyleSheet = "QSlider {padding-left: 80px; padding-right: 80px;} \n"
"QSlider::handle:horizontal{image: url(:/images/FanSlider/blowerSw2.png);}\n"
"QSlider::groove:horizontal{background-image: url(:/images/FanSlider/barind.png);}\n";
Upvotes: 0