Hi everyone,
I have to set float values to horizontal slider. How can I do it?
thanks in advance
jakr1387
Hi everyone,
I have to set float values to horizontal slider. How can I do it?
thanks in advance
jakr1387
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 for some documentation.
Last edited by d_stranz; 10th September 2014 at 20:19. Reason: Fixed docs URL.
When checking QwtSlider better have a look at a more recent version of the docs.
Uwe
d_stranz (10th September 2014)
Bookmarks