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. An Easy Answer For An Old Hand
Forum Update on Tuesday, May 27th 2025

An Easy Answer For An Old Hand

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 4 Posters 666 Views 2 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.
  • S Offline
    S Offline
    ShylerC
    wrote on last edited by
    #1

    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.HilkJ 2 Replies Last reply
    0
    • S ShylerC

      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 Offline
      K Offline
      kenchan
      wrote on last edited by
      #2

      @ShylerC You can use the other slot for that

      void QSpinBox::valueChanged(int i)
      
      1 Reply Last reply
      5
      • S ShylerC

        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();
        }

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @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


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

        1 Reply Last reply
        5
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          0

          • Login

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