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

10th September 2014, 07:28
Hi everyone,

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

thanks in advance

10th September 2014, 16: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.

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