Results 1 to 4 of 4

Thread: Is It possible to show zeros numbers after decimal point in a QLabel?

  1. #1

    Default Is It possible to show zeros numbers after decimal point in a QLabel?

    Hello, this is my first question in this forum, sorry if I make a mistake.
    Im using a QLabel to show float numbers, that is working, my problem is that I want to show ever two numbers after the decimal point. eg If the number is 1.55 shows 1.55, but whe the numer is 1.50 shows 1.5 and I want to show 1.50 or if the number is 1.00 shows 1 and I want to show 1.00.
    I am using setNum(number) to show the value.
    Any suggestion? anywone can help me?
    Thanks

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Is It possible to show zeros numbers after decimal point in a QLabel?

    Doesn't QString::number with the 'g' format specifier do what you want?

    Edit: Sorry, misread your post, you want the format specifier 'f' with precision of 2.
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  3. #3
    Join Date
    Oct 2006
    Posts
    105
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Is It possible to show zeros numbers after decimal point in a QLabel?


  4. #4

    Default Re: Is It possible to show zeros numbers after decimal point in a QLabel?

    Yes i coul resolve it, thanks for you reply

    Thank you, i could resolve it

Similar Threads

  1. QAbstractItemModel, QTableWidget. Decimal point.
    By shestero in forum Qt Programming
    Replies: 5
    Last Post: 23rd July 2014, 19:11
  2. Replies: 1
    Last Post: 21st December 2012, 11:00
  3. QLineEdit for editing hexadecimal and decimal numbers
    By schall_l in forum Qt Programming
    Replies: 2
    Last Post: 28th April 2012, 11:38
  4. To underline the numbers behind the decimal points?
    By wookoon in forum Qt Programming
    Replies: 3
    Last Post: 14th December 2010, 23:01
  5. QPainter clipping with precision behind the decimal point
    By Pieter from Belgium in forum Qt Programming
    Replies: 0
    Last Post: 14th March 2007, 13:30

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.