Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reverse a QSlider's range

Tags:

c++

qt

qslider

i am stuck at trying to reverse the range of a QSlider such that abs(maxVal) always stays on top.

slider->setRange[0,maxVal] should look like the slider on the right

slider->setRange[-maxVal,0] should be reversed/rotated.

enter image description here

What i could do is not to reverse the range, set a "-" prefix in the SpinBox above and multiply the value by -1 when reading. I just wonder if there is the possibility to swap the direction of the slider.

like image 560
jonnyx Avatar asked Nov 16 '25 03:11

jonnyx


1 Answers

You should be able to invert the slider, setting the invertedAppearance property to true:

slider->setRange(-maxVal, 0); 
slider->setInvertedAppearance(true);
like image 131
p-a-o-l-o Avatar answered Nov 17 '25 20:11

p-a-o-l-o



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!