PDA

View Full Version : QScrollBar setValue() vs setSliderPosition()



Debra
14th June 2019, 16:43
I am using a QScrollArea. I would like to change the position of it by setting the vertical scrollbar's position. There are two possible methods setValue() and setSliderPosition(). The documentation states that the difference between them is that there is tracking on one of them. What is meant by tracking?
I look forward to hearing from you.

ChrisW67
15th June 2019, 06:14
From QAbstractSlider (https://doc.qt.io/qt-5/qabstractslider.html#tracking-prop):

If tracking is enabled (the default), the slider emits the valueChanged() signal while the slider is being dragged. If tracking is disabled, the slider emits the valueChanged() signal only when the user releases the slider.

and here (https://doc.qt.io/qt-5/qabstractslider.html#sliderMoved):

This signal is emitted even when tracking is turned off.

I assume setValue() will honour the tracking behaviour, and setSliderPosition() will always announce changes through sliderMoved() even when tracking is off.