Results 1 to 3 of 3

Thread: Remove traling zeros from QString scientific notation num value

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2025
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Remove traling zeros from QString scientific notation num value

    QString cStyleResult = QString::number(valor, 'e', 6); // Set precision to 6.
    cStyleResult = cStyleResult.remove(QRegExp("0+$")); // Remove trailing zeros.
    cStyleResult = cStyleResult.remove(QRegExp("\\.$")); // Remove trailing dot if any.
    This should give you the desired output without trailing zeros.

    Moderator's note: Spam link removed. No more warnings, you will be banned.
    Last edited by d_stranz; 7th January 2025 at 16:56. Reason: removed URL

Similar Threads

  1. Replies: 1
    Last Post: 9th March 2019, 09:15
  2. Remove \n from QString
    By arturs in forum Newbie
    Replies: 4
    Last Post: 20th April 2015, 08:41
  3. Replies: 3
    Last Post: 17th April 2010, 21:35
  4. qdoublespinbox with scientific notation
    By pospiech in forum Qt Programming
    Replies: 13
    Last Post: 3rd January 2009, 14:50
  5. QString:: Padding Zeros?
    By Harvey West in forum Qt Programming
    Replies: 2
    Last Post: 27th February 2007, 18:25

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
  •  
Qt is a trademark of The Qt Company.