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. Getting value from QSpinbox and setting to 1 decimal place.
Forum Updated to NodeBB v4.3 + New Features

Getting value from QSpinbox and setting to 1 decimal place.

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 342 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.
  • James SprinksJ Offline
    James SprinksJ Offline
    James Sprinks
    wrote on last edited by
    #1

    Hi All

    I need to pull the value of a QSpinbox, set it to a double variable - but to one decimal place.

    I have set the variable:

    double decimal = ui->manualRate->value();
    

    I am wondering how I now set this double to one decimal place?

    Thanks

    J

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      decimal = static_cast<double>(qRound(decimal*10.0))/10.0

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      1 Reply Last reply
      4

      • Login

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