qslider fixed to tick marks
Hi,
I need that the Slider moves not to be continous, only from a tick to another ignoring the space (and therefore the values) between the 2 ticks.
I see how create the ticks with setTickPosition() and setTickInterval(), but nothing to fix the slider handle to the ticks.
Any idea?
Re: qslider fixed to tick marks
Code:
slider.setTickInterval(1);
slider.setRange(0,40); // where 40 is your "tick count"
Re: qslider fixed to tick marks
I see, so the movement from a tick to another always is 1 unit.
For example, for a slider that only can take the values 0->25->50->75->100, I have to create a slider from 0->4 with tickInterval=1, and then multiply the value by 4.
Code:
slider.setTickInterval(1);
slider.setRange(0,4);
...
int nPercentVal = slider.value() * 4;
So, isn't a way to avoid that multiplication (setting range 0->100) but slider handle only moving through 5 ticks in the slider?
Re: qslider fixed to tick marks
Sorry... I mean
Code:
int nPercentVal = slider.value() * 25;
:)
Re: qslider fixed to tick marks
Well, I see no possibility for that. But you can easy subclass QSlider and change the value setter and getter function with a custom factor.