Important: Please read the Qt Code of Conduct -

Padding on elements without stylesheets

  • Hi,

    I want to create custom sliders by subclassing QSlider. However, since I don't use padding in the pressEvent or paintEvent, I can't use it to "scale" the slider inside the bounding rectangle.

    The question is what I could use to add a "padding" to the slider instead. Using layout->setContentsMargin() or something doesn't seem to help.

    Any ideas?

  • Qt Champions 2017

    What is the you would like to customize the QSlider ? You would like reduce the size of QSlider based on the available size of you bounding widget ? Some more details would help.

  • Hi,

    I m working width() and height() in the paintEvent to get the size of the Slider. I would like to specify a margin between the Slider and the layout it's in to have some pixels between them.

    The problem is that the Slider uses a size policy set to prefered / prefered so it seems stuff like layout->setContentsMargin(....) didn't worked...

Log in to reply