How to use stylesheet to customize handle of QSlider on MacOS

Royt picture Royt · Apr 25, 2012 · Viewed 8.6k times · Source

On MacOS 10.6, the default handle of QSlider is a ball, if a QSlider has ticks, then the handle changes its appearence (one side arrow shape), I want this kind of handle, but I don't like the ticks Qt provides. So, I'd like to store that picture of handle as qrc resource and use stylesheet to customize the look of qslider. That's the only way I can figure out.

Could anyone tell me how to write the style sheet, I mean that everything keep the same but only the handle changes.

BTW, there's another question. For a default QSlider on MacOS, the handle can't reach to the most left and most right position of the groove, how to use stylesheet to adjust it?

Answer

Kamil Klimek picture Kamil Klimek · Apr 25, 2012

You must change entire QSlider to manage such things. Otherwise it will fallback into default Mac OS X painting style. So you must change border and background of QSlider and handle itself. Take a look at this example