Skip to content Skip to sidebar Skip to footer

How To Change QSlider Handle Width Using Stylesheet

I have an application that I wan't to run on a 10' touch screen. I am trying to make the QSlider handle larger so it will be easier to move. I have found plenty of examples of ch

Solution 1:

To get this to work, I found that a border must be set on the groove component. Also, to make the handle larger than the groove, a negative margin has to be set on the handle (see Customizing QSlider in the Qt Docs):

QSlider::groove:horizontal {
    border: 1px solid;
    height: 10px;
    margin: 0px;
    }
QSlider::handle:horizontal {
    background-color: black;
    border: 1px solid;
    height: 40px;
    width: 40px;
    margin: -15px 0px;
    }

PS: If the slider is added to a layout, it might be necessary to set its minimum height in order to stop it being squashed back to its original dimensions.


Post a Comment for "How To Change QSlider Handle Width Using Stylesheet"