Results 1 to 5 of 5

Thread: QString::number(v, 'g', 3), how to change limits of 'g' for log. values

  1. #1
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default QString::number(v, 'g', 3), how to change limits of 'g' for log. values

    Hi,

    have values (v) from 2000 to 1E-10 and with that i got on a logarithmic axis

    1000, 100, 10, 1, 0.1, 0.01, 0.001, 0.0001, 1E-05 ... and so on

    How to modifiy it that values below 0.01 are in e-format

    1000, 100, 10, 1, 0.1, 0.01, 1e-3, 1e-4, 1e-5 ...

    Thx

  2. #2
    Join Date
    Jul 2015
    Posts
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QString::number(v, 'g', 3), how to change limits of 'g' for log. values

    Hi,

    change the 'g' to 'e' or 'E' as you can see here.

  3. #3
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QString::number(v, 'g', 3), how to change limits of 'g' for log. values

    Quote Originally Posted by STM View Post
    Hi,

    change the 'g' to 'e' or 'E' as you can see here.
    You didn't understand it, that changes ALL values into e-format, not only some.
    Nevermind, i found it by myself.

  4. #4
    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: QString::number(v, 'g', 3), how to change limits of 'g' for log. values

    Nevermind, i found it by myself.
    Well, good. Keep it a secret. After all, the purpose of this forum isn't really to share information, it's to get help for yourself only, right?

  5. #5
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QString::number(v, 'g', 3), how to change limits of 'g' for log. values

    Quote Originally Posted by d_stranz View Post
    Well, good. Keep it a secret. After all, the purpose of this forum isn't really to share information, it's to get help for yourself only, right?
    No panic, i had already written it here. Can i check it first if it realy works? Right?


    The only solution i found was to check the value in a func an return it formated.

    Qt Code:
    1. if( v >= 1E-1 )
    2. return QString::number(v, 'G', 3);
    3. else
    4. return QString::number(v, 'e', 0);
    To copy to clipboard, switch view to plain text mode 

  6. The following user says thank you to HappyCoder for this useful post:

    d_stranz (27th July 2015)

Similar Threads

  1. Replies: 7
    Last Post: 3rd April 2014, 12:56
  2. Replies: 4
    Last Post: 13th May 2013, 21:29
  3. Strange QString::number behaviour
    By sastrian in forum Qt Programming
    Replies: 1
    Last Post: 7th September 2012, 08:29
  4. Replies: 4
    Last Post: 1st February 2010, 14:21
  5. strange problem about QString::number(double)
    By yuzr in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 24th December 2007, 13:05

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.