Change the size of QSlider::handle not working

  • Hello! I am trying to use a custom style sheet styled QSlider. I would like a aspect ratio on the handle different than the one provided by default. However, the height and width attributes in the style sheet don't work, probably because they might be overridden when I resize my slider in the resize event. I specifically would like the slider short but wide. Does anyone have any advice on how to do this? Thanks!

  • Hi,
    Not really sure what you want, but do you need a fixed size QSlider? When the properties for height and width are set to fixed size, the resize event will not overwrite them. If you really want control how your slider is displayed you could create your own and use the paintevent to draw the widget the way you want it to look.

  • Moderators

    you can give QProxyStyle a shot and overload "QProxyStyle::pixelMetric()": and return the desired size for QStyle::PM_SliderControlThickness.
    There are some examples of QProxyStyle usage on the web, or read the example of the "docs":

  • i would like to change the aspect ratio of the slider handle, right now it is tall but not wide, I would like it wide but not tall. but the height attributes have no effect

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.