Results 1 to 2 of 2

Thread: Convert number

  1. #1
    Join Date
    May 2018
    Posts
    19
    Thanks
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Convert number

    I used
    Qt Code:
    1. QString::number(number, 'f', 2)
    To copy to clipboard, switch view to plain text mode 
    When I put 1.3, 1, 1.1111
    the console show: 1.30 1.00, 1.11
    BUT How to remove the last 0 number: 1.3, 1, 1.11

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    506
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Convert number

    With format 'f' the last number (2 in your example) defines the number of digits after the decimal point.
    See http://doc.qt.io/qt-5/qstring.html#argument-formats

    Ginsengelf

Similar Threads

  1. Replies: 6
    Last Post: 30th September 2015, 20:20
  2. Replies: 6
    Last Post: 30th December 2012, 22:10
  3. lcd number set value
    By hezbon in forum Newbie
    Replies: 5
    Last Post: 18th July 2012, 09:58
  4. Replies: 1
    Last Post: 5th March 2012, 06:34
  5. Number PI
    By digog in forum Newbie
    Replies: 5
    Last Post: 25th April 2011, 01:50

Tags for this Thread

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.