PDA

View Full Version : How to convert Qhorizontal_Slider int value to float!!



Jakr1387
10th September 2014, 08:28
Hi everyone,

I have to set float values to horizontal slider. How can I do it?


thanks in advance
jakr1387

d_stranz
10th September 2014, 17:10
QSlider only works with integer valued positions and range. To use it with floating point values, you have to map the floating point range to an integer range. For example, if your floating point range is 0.0 - 1.0, you can map this to the integer range 0 - 100. A floating point value of 0.25 is then 25 on this scale.

Alternatively, you can use the QwtSlider class from the Qwt library. This works directly with double valued positions and ranges. See here (http://qwt.sourceforge.net/class_qwt_slider.html) for some documentation.

Uwe
10th September 2014, 17:26
When checking QwtSlider better have a look at a more recent version of the docs (http://qwt.sourceforge.net/class_qwt_slider.html).

Uwe