How to change QSlider handle width using stylesheet

后端 未结 1 1885
别跟我提以往
别跟我提以往 2021-01-23 08:35

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

1条回答
  •  隐瞒了意图╮
    2021-01-23 09:23

    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.

    0 讨论(0)
提交回复
热议问题