Results 1 to 6 of 6

Thread: QProgressBar with % in decimal

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2020
    Posts
    53
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QProgressBar with % in decimal

    But the setValue() method converts the input argument to int, so the fractional part of the value is lost.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,316
    Thanks
    315
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QProgressBar with % in decimal

    But the setValue() method converts the input argument to int, so the fractional part of the value is lost.
    Change the scale of the progress bar range. If you now have it set to range from 0 - 100, and you want one decimal place, change it to a range of 0 - 1000. Use ChrisW67's method to format the text by converting the value to a float, dividing by 10, and use the result to set a float formatted string.

    You will also have to change the code that sets the value to multiply the number passed to setValue() by 10.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jan 2020
    Posts
    53
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: QProgressBar with % in decimal

    Works perfectly! Thanks. I tried to find a good excuse for not thinking of this myself, but couldn't find one ...

Similar Threads

  1. Qt and decimal number
    By Imhotep in forum Newbie
    Replies: 2
    Last Post: 19th September 2016, 16:41
  2. comma as decimal seperator
    By Malisha100ka in forum Qt Programming
    Replies: 2
    Last Post: 26th August 2015, 21:35
  3. Decimal to Binary conversion
    By anh5kor in forum Newbie
    Replies: 1
    Last Post: 5th February 2015, 12:16
  4. QTableWidget and Decimal places
    By pshah.mumbai in forum Qt Programming
    Replies: 3
    Last Post: 17th August 2008, 08:30
  5. converting the value from hexadecimal to decimal value
    By jjbabu in forum Qt Programming
    Replies: 2
    Last Post: 16th November 2007, 10:24

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
  •  
Qt is a trademark of The Qt Company.