Results 1 to 3 of 3

Thread: QString formatting issue.

  1. #1
    Join Date
    Jun 2008
    Posts
    25
    Thanks
    9
    Thanked 1 Time in 1 Post

    Default QString formatting issue.

    Qt Code:
    1. double dValue = 0.00200;
    2. QString strValue = QString::number(dValue, 'e', 1);
    To copy to clipboard, switch view to plain text mode 

    The strValue is getting as 2.0e-03

    I don't want the preceding zeros in the exponent part. How can i do that ?

  2. #2
    Join Date
    Dec 2008
    Location
    TaganrogNativelandChehov,Russia
    Posts
    64
    Thanks
    1
    Thanked 8 Times in 7 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QString formatting issue.

    i think only QRegExp helps you.

    may be like this
    Qt Code:
    1. QRegExp reg("(e[+-])([0]+)([0-9]+)");
    2. int pos = reg.indexIn(strValue);
    3. if(pos!=-1){
    4. strValue.replace(reg,reg.cap(1) + reg.cap(3));
    5. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by kwisp; 22nd October 2009 at 09:02.
    east or west home is best

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

    George Neil (22nd October 2009)

  4. #3
    Join Date
    Jun 2008
    Posts
    25
    Thanks
    9
    Thanked 1 Time in 1 Post

    Default Re: QString formatting issue.

    Great.... That works.....

Similar Threads

  1. Qy 4.4.3 MySQL driver failed
    By pamalite in forum Installation and Deployment
    Replies: 2
    Last Post: 23rd January 2010, 02:09
  2. File rename detection
    By bunjee in forum Qt Programming
    Replies: 6
    Last Post: 23rd July 2009, 16:22
  3. Custom Model Advice Requested
    By mclark in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2008, 17:26
  4. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 18:59
  5. Formatting a QString
    By icentenee in forum Newbie
    Replies: 9
    Last Post: 1st October 2006, 18:41

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.