PDA

View Full Version : QwtSlider with zero range



Induriel
19th October 2015, 12:08
Hi,

this may sound strange, but I have a use case where one can set the range of a QwtSlider i.e. to (50.0, 50.0). This is meant to nail a variable to a fixed value.
As far as I understood the code, QwtAbstractScale::rescale() is called when borders are set and if upperBorder == lowerBorder, it seems the value is set to 0. My first idea was to reimplement QwtAbstractScale::rescale(), but this function isn't virtual. The drawing part is not important in my case, I do not use drawn scales.
Did I understand anything wrong or is there a way to get around this behaviour? Or do I have to build some wrapper around QwtSlider to catch this case?

Thanks in advance,
Carsten

Uwe
20th October 2015, 07:31
What about slider->setReadOnly( true ) ?

Uwe

Induriel
20th October 2015, 13:35
Uwe,

thanks for your answer.
The borders of the slider are changed @runtime. At the moment the borders are set, rescale() is called. So it doesn't help to make it read only. The basic problem is that the value of the slider is set to 0 if borders have the same value.

Best regards,
Carsten

Uwe
20th October 2015, 14:05
Thought you want to nail a fixed value - why do you have to narrow the borders for this ?
But anyway: a slider with an empty range doesn't make any sense as you don't have a slider position then.

Uwe

Induriel
20th October 2015, 15:22
Ok, to give a more complete explanation: our machines are able to pulse some light with a frequency. The frequency can be adjusted by the user in a specific range, set by our service personal. There are some machines which should pulse only on a single frequency, so our service is used to set upper border and lower border to the same value.

Anyway, I had the same use case with Qwt5.2.1, and it worked there (setting upper border and lower border to let's say 50 and slider->value() gives me 50). The behaviour in Qwt6.1.2 is different, slider->value() gives me 0. The range is not empty (may depend on the definition of empty of course), and I think there is a position for the thumb - 50. Even if the thumb cannot move.

Hopefully this explains my problem better. Sorry for the confusion!

Thanks,
Carsten

Uwe
20th October 2015, 15:42
Each position of a slider corresponds to a value, and each value to a position - otherwise it doesn't work. So what should happen when all positions of the slider correspond to 50 - where to draw the handle ?
But why not simply setting some valid range and putting the slider into read only mode, when the user sets an empty range ?

Uwe

Induriel
29th October 2015, 18:44
I implemented it as you suggested, it works fine.
Thanks for your help,
Carsten