QSlider how to check if slider handle is selected
Hi,
I am trying to get the slider handle to move only when it is selected and drag. I have subclass the QSlider class , re-implementing the mousePressEvent function.
In my mousePressEvent function.
Code:
if (d
->pressedControl
!= QStyle::SC_SliderHandle)
I am unable to access d_func() as it is private , is there any work around so i am able to check if the selected object is the slider handle?
Re: QSlider how to check if slider handle is selected
Why are you going so low level?
Why not just use sliderPressed() signal?
Or even better, sliderMoved()?
http://qt-project.org/doc/qt-4.8/qab...ml#sliderMoved
Re: QSlider how to check if slider handle is selected
I don't think you can do that in a subclass.
What you could try it so overwrite sliderChange() and check for value changes.
If the slider is pressed at the time you allow it to pass, if not, you don't. The latter might require to reset the value
Other options are to modify the slider implementation in your copy of Qt or copy the slider implementation in to a new class and have it in a separate "addon" library
Cheers,
_
Re: QSlider how to check if slider handle is selected
Quote:
I am trying to get the slider handle to move only when it is selected and drag.
but isn't this the normal QSlider behavior?
From the docs for QAbstractSlider::sliderMoved ( int value ):
Quote:
This signal is emitted when sliderDown is true and the slider moves. This usually happens when the user is dragging the slider. The value is the new slider position.
This signal is emitted even when tracking is turned off.
Otherwise, what exactly do you mean by "selected and drag"?