PDA

View Full Version : QScrollBar: custom slider's size ?



deweyjew
9th May 2006, 01:50
hi:
How to resize slider in QScrollBar manually ?

thanks!

guilugi
9th May 2006, 09:57
Hi,

You have to subclass a QStyle object, and change some Pixel Metric settings for your slider.
Here, you have a list of parameters that can be tuneds :
http://doc.trolltech.com/4.1/qstyle.html#PixelMetric-enum

In your custom style class, you have to reimplement those values in this method :


int myStyle::pixelMetric(PixelMetric metric,
const QStyleOption *option,
const QWidget *widget) const
{
switch (metric)
{
case PM_SliderLength :
return 20; // Here, just put the length you want
....
....
}



You can check the styles example in the docs ;)

Guilugi.