PDA

View Full Version : QSlider: direct jump



mpi
24th August 2010, 14:02
When I press the left mouse button on a QSlider, it only does a certain page-step instead of jumping directly to the point that the mouse cursor points at. Is there anyway, I can make it jump directly to the point? I believe this is the standard behavior found in all movie players.

Mads

j_kubik
21st July 2011, 20:34
I think you should subclass QProxyStyle to change return value of QStyle::SH_Slider_AbsoluteSetButtons hint in styleHint method. Something like that:

class SliderStyle: public QProxyStyle{
public:
virtual int styleHint ( StyleHint hint, const QStyleOption * option = 0, const QWidget * widget = 0, QStyleHintReturn * returnData = 0 ) const{
if (hint == QStyle::SH_Slider_AbsoluteSetButtons){
return Qt::LeftButton;
}else{
return QProxyStyle::styleHint(hint, option, widget, returnData);
}
}
};

Then create new SliderStyle and set is as your QSlider style.

syclopse
22nd July 2011, 07:02
you can write in mousepressed event to set the value of the QSlider to the selected value,
using checking the widget==QSlider in eventfilter ....