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. QOBject::tr() with floating-point number

QOBject::tr() with floating-point number

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 399 Views
  • 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.
  • F Offline
    F Offline
    fem_dev
    wrote on last edited by
    #1

    I would like to get the QMessageBox showing the double precision value of the variable my_double. But I got it showing the value 0.

    double my_double = 0.1234567;
    
    QMessageBox::warning(
        nullptr,
        QObject::tr("Warning"),
        QObject::tr("The value %n is a double precision number", "", my_double),
        QMessageBox::Ok);
    

    How can I do it?

    aha_1980A 1 Reply Last reply
    0
    • M Offline
      M Offline
      mpergand
      wrote on last edited by
      #4
      QObject::tr("The value %1 is a double precision number").arg( my_double),
      
      F 1 Reply Last reply
      4
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi,

        Are you looking for QLocale::toString ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        2
        • F fem_dev

          I would like to get the QMessageBox showing the double precision value of the variable my_double. But I got it showing the value 0.

          double my_double = 0.1234567;
          
          QMessageBox::warning(
              nullptr,
              QObject::tr("Warning"),
              QObject::tr("The value %n is a double precision number", "", my_double),
              QMessageBox::Ok);
          

          How can I do it?

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

          @fem_dev I guess %n is for natural, countable things. What would you expect as singular/plural for a double?

          Regards

          Qt has to stay free or it will die.

          1 Reply Last reply
          3
          • M Offline
            M Offline
            mpergand
            wrote on last edited by
            #4
            QObject::tr("The value %1 is a double precision number").arg( my_double),
            
            F 1 Reply Last reply
            4
            • M mpergand
              QObject::tr("The value %1 is a double precision number").arg( my_double),
              
              F Offline
              F Offline
              fem_dev
              wrote on last edited by
              #5

              @mpergand said in QOBject::tr() with floating-point number:

              QObject::tr("The value %1 is a double precision number").arg( my_double),
              

              Thank you @mpergand ! This solution works great!

              1 Reply Last reply
              1

              • Login

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