Results 1 to 2 of 2

Thread: setNum() digits question

  1. #1
    Join Date
    Nov 2007
    Posts
    103
    Thanks
    71
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default setNum() digits question

    I am using a QLabel to display a number which ia a double.
    Qt Code:
    1. void QLabel::setNum ( double num )
    To copy to clipboard, switch view to plain text mode 
    I don't want so many significant digits. How do I cut the number of significant digits?
    I want 1.2345678 to display as 1.23

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setNum() digits question

    Qt Code:
    1. s = s.setNum(1.2345678, 'g', 2);
    2. label->setText(s);
    To copy to clipboard, switch view to plain text mode 

  3. The following user says thank you to marcel for this useful post:

    tommy (23rd January 2008)

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.