Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Solved An Easy Answer For An Old Hand

    General and Desktop
    4
    4
    495
    Loading More Posts
    • 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.
    • S
      ShylerC last edited by

      This is probably the silliest question on the planet -

      But when my user enters a value into a spin box - how do I make sure it comes as only an int? I need to perform math on it ... and I am so new - the help docs help a little - but very cryptic in the beginning.

      So basically - What I have is below. I can pull values from the GUI no problem - but I want the value to be an integer.

      void MainWindow::on_spinBox_valueChanged(const QString)
      {
      QString days;
      days=ui->spinBox->text();
      }

      K J.Hilk 2 Replies Last reply Reply Quote 0
      • K
        kenchan @ShylerC last edited by

        @ShylerC You can use the other slot for that

        void QSpinBox::valueChanged(int i)
        
        1 Reply Last reply Reply Quote 5
        • J.Hilk
          J.Hilk Moderators @ShylerC last edited by

          @ShylerC
          you should take your time and take a look at the documentation of Qt

          it's is very detailed and in 90% off all case has the answer to your questions

          for example:

          QSpinBox-docu section Value
          0_1523941019714_c8464f35-9cc7-4896-86b5-f07e3cd744f2-image.png

          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct

          Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          1 Reply Last reply Reply Quote 5
          • mrjj
            mrjj Lifetime Qt Champion last edited by

            Hi

            • This is probably the silliest question on the planet
              Oh no, not even close. :)

            Anyway, just want to say that
            QString also have
            http://doc.qt.io/qt-5/qstring.html#toInt
            and toDouble
            for such conversations in case other time there
            is not a signal with the right type.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post