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. QInputDialog::getDouble only take int,but not double
Forum Updated to NodeBB v4.3 + New Features

QInputDialog::getDouble only take int,but not double

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 737 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.
  • M Offline
    M Offline
    Mikee
    wrote on last edited by
    #1

    Hi.

    bool ok;
       double d = QInputDialog::getDouble(this, tr("ParametrForStrategy"),
                                              tr("double:"), 37.56, -10000, 10000, 0.01, &ok);
       if (ok) {qDebug()<<d;}
    

    In dialog window I can only enter int, but not double. How to fix it?

    dream_captainD 1 Reply Last reply
    0
    • M Mikee

      Hi.

      bool ok;
         double d = QInputDialog::getDouble(this, tr("ParametrForStrategy"),
                                                tr("double:"), 37.56, -10000, 10000, 0.01, &ok);
         if (ok) {qDebug()<<d;}
      

      In dialog window I can only enter int, but not double. How to fix it?

      dream_captainD Offline
      dream_captainD Offline
      dream_captain
      wrote on last edited by
      #2

      @Mikee

      bool ok;
      double d = QInputDialog::getDouble(this, tr("ParametrForStrategy"),
                                                tr("double:"), 37.56, -10000, 10000, 0.01, &ok);
      if (ok) {qDebug()<<d;}
      

      Your seventh argument is incorrect. Documentation says that decimals is the maximum number of decimal places the number may have. Corrected version:

      bool ok;
      double d = QInputDialog::getDouble(this, tr("ParametrForStrategy"),
                                                tr("double:"), 37.56, -10000, 10000, 2, &ok);
      if (ok) {qDebug()<<d;}
      
      1 Reply Last reply
      6
      • M Offline
        M Offline
        Mikee
        wrote on last edited by
        #3

        thank you

        1 Reply Last reply
        0

        • Login

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