Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How write numbers
Forum Updated to NodeBB v4.3 + New Features

How write numbers

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 392 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I'd like writing convert a number in a Qstring in this way:
    if the numbers is: 7.4

    I would like convert in this way:
    07.40

    aha_1980A 1 Reply Last reply
    0
    • M Offline
      M Offline
      mad-hatter
      wrote on last edited by
      #2

      From the QString header.

         QString &QString::prepend(const QString &str)
         QString &QString::append(const QString &str)
      
      1 Reply Last reply
      0
      • ? A Former User

        I'd like writing convert a number in a Qstring in this way:
        if the numbers is: 7.4

        I would like convert in this way:
        07.40

        aha_1980A Offline
        aha_1980A Offline
        aha_1980
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @vale88

        #include <QDebug>
        
        int main(int argc, char *argv[])
        {
            double d = 7.4;
            QString s = QString("%1").arg(d, 5, 'f', 2, QChar('0'));
            qDebug() << s;
        }
        

        Qt has to stay free or it will die.

        1 Reply Last reply
        6

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved