PDA

View Full Version : QSlider problem



sincnarf
10th October 2007, 01:03
I am trying to get float values from a QSlider, but the problem is the QSlider only supports integers... and each slide can only support integer values too. I need float/double values. Is there an alternative for this?

Here's a simple solution but does not work too. I tried setting my QSlider's minimum and maximum values to -1000 and 1000 so that I can just divide the integer values by 1000 again to get float values in the end. But all I get are zero values. What's wrong ?


qDebug("Slider val: %.30lf", (float) (value / 1000));
Dragging the slider to the minimum I get
Slider val: -1.000000000000000000000000000000

Dragging the slider to the maximum I get
Slider val: 1.000000000000000000000000000000

but all values in the middle of maximum and minimum I get
Slider val: 0.000000000000000000000000000000

jacek
10th October 2007, 01:07
5 / 2 = 2
5.0 / 2.0 = 2.5