Results 1 to 3 of 3

Thread: How to convert Qhorizontal_Slider int value to float!!

  1. #1
    Join Date
    Aug 2014
    Posts
    9
    Thanks
    2
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question How to convert Qhorizontal_Slider int value to float!!

    Hi everyone,

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


    thanks in advance
    jakr1387

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to convert Qhorizontal_Slider int value to float!!

    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.

  3. #3
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to convert Qhorizontal_Slider int value to float!!

    When checking QwtSlider better have a look at a more recent version of the docs.

    Uwe

  4. The following user says thank you to Uwe for this useful post:

    d_stranz (10th September 2014)

Similar Threads

  1. Multi defined QVector<float>::QVector<float>
    By lni in forum Qt Programming
    Replies: 1
    Last Post: 6th May 2013, 07:58
  2. Replies: 6
    Last Post: 1st February 2013, 08:32
  3. Replies: 4
    Last Post: 18th May 2011, 17:59
  4. How to convert int to float?
    By babygal in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2010, 05:06
  5. Replies: 1
    Last Post: 10th February 2009, 09:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.