from drawComplexControl:
NewOptions.subControls &= ~SC_SliderHandle;
DefaultStyle->drawComplexControl(control, &NewOptions, painter, widget);
//manually drawing the handle
QRect HandlePos
= DefaultStyle
->subControlRect
(CC_Slider, option, SC_SliderHandle
);
QRect PicRect
= sliderPicture
->rect
();
PicRect.moveCenter(HandlePos.center());
painter->drawPixmap(PicRect, *sliderPicture, sliderPicture->rect());
QStyleOptionSlider NewOptions(*StyleOptions);
NewOptions.subControls &= ~SC_SliderHandle;
DefaultStyle->drawComplexControl(control, &NewOptions, painter, widget);
//manually drawing the handle
QRect HandlePos = DefaultStyle->subControlRect(CC_Slider, option, SC_SliderHandle);
QRect PicRect = sliderPicture->rect();
PicRect.moveCenter(HandlePos.center());
painter->drawPixmap(PicRect, *sliderPicture, sliderPicture->rect());
To copy to clipboard, switch view to plain text mode
from pixelMetric:
if (QStyle::PM_SliderSpaceAvailable == metric
) return DefaultStyle->pixelMetric(metric, option, widget) - sliderPicture->width();
if (QStyle::PM_SliderThickness == metric
) return sliderPicture->height();
return DefaultStyle->pixelMetric(metric, option, widget);
QStyle* DefaultStyle = QApplication::style();
if (QStyle::PM_SliderSpaceAvailable == metric)
return DefaultStyle->pixelMetric(metric, option, widget) - sliderPicture->width();
if (QStyle::PM_SliderThickness == metric)
return sliderPicture->height();
return DefaultStyle->pixelMetric(metric, option, widget);
To copy to clipboard, switch view to plain text mode
The slider is horizontal, so when the handle is at one of the extreme edged, the pixmap is clipped. I'll post a picture later today. Thanks!
Bookmarks