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. Double Spin Box Save to the file
Forum Update on Monday, May 27th 2025

Double Spin Box Save to the file

Scheduled Pinned Locked Moved Unsolved General and Desktop
doublespinboxsavefilespinbox
7 Posts 3 Posters 1.4k 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.
  • D Offline
    D Offline
    deleted286
    wrote on 10 Feb 2021, 14:04 last edited by
    #1

    I have 2 labels and 2 double spinbox. I want to save my datas a txt file which i changed them on double spinbox. How can i do it?

    Screenshot from 2021-02-10 17-01-07.png

    J P 2 Replies Last reply 10 Feb 2021, 15:17
    0
    • D deleted286
      10 Feb 2021, 14:04

      I have 2 labels and 2 double spinbox. I want to save my datas a txt file which i changed them on double spinbox. How can i do it?

      Screenshot from 2021-02-10 17-01-07.png

      J Offline
      J Offline
      JonB
      wrote on 10 Feb 2021, 15:17 last edited by JonB 2 Oct 2021, 15:24
      #2

      @suslucoder
      Put slot on void void QDoubleSpinBox::valueChanged(double d) (or possibly on textChanged instead/as well, depends what you want).

      Oh, that was assuming your question meant "save to file as soon as the user changes the value in one of the spin boxes". If you just mean there is a Save button, then in the slot for it being clicked simply pick up the current values from the spin boxes and save them to file, nothing else to say.

      1 Reply Last reply
      0
      • D deleted286
        10 Feb 2021, 14:04

        I have 2 labels and 2 double spinbox. I want to save my datas a txt file which i changed them on double spinbox. How can i do it?

        Screenshot from 2021-02-10 17-01-07.png

        P Offline
        P Offline
        Pl45m4
        wrote on 10 Feb 2021, 15:47 last edited by Pl45m4 2 Oct 2021, 15:52
        #3

        @suslucoder

        Assuming these are application settings (for your QChart axis), you can use QSettings

        • https://doc.qt.io/qt-5/qsettings.html#restoring-the-state-of-a-gui-application

        If not, do as @JonB suggested:

        Just take the current values from your spinBoxes and write them to your file, when pressing the Save-button (in a slot connected to button clicked signal).


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        D 1 Reply Last reply 11 Feb 2021, 10:28
        0
        • P Pl45m4
          10 Feb 2021, 15:47

          @suslucoder

          Assuming these are application settings (for your QChart axis), you can use QSettings

          • https://doc.qt.io/qt-5/qsettings.html#restoring-the-state-of-a-gui-application

          If not, do as @JonB suggested:

          Just take the current values from your spinBoxes and write them to your file, when pressing the Save-button (in a slot connected to button clicked signal).

          D Offline
          D Offline
          deleted286
          wrote on 11 Feb 2021, 10:28 last edited by
          #4

          @Pl45m4 I did it in that way. But in the future i will have more than 50 lineEdit.
          Is there any easy way to do it?

          QFile file("/home/veriler.txt");
          file.open(QIODevice::WriteOnly | QIODevice::Text);
          QApplication::processEvents();
          QString nktkabul;
          nktkabul= ui->nktKbl->text();
          
          QString mingorv;
          mingorv = ui->minGrv->text();
          
          QTextStream out(&file);
          out<<nktkabul << mingorv;
          
          J 1 Reply Last reply 11 Feb 2021, 10:41
          0
          • D deleted286
            11 Feb 2021, 10:28

            @Pl45m4 I did it in that way. But in the future i will have more than 50 lineEdit.
            Is there any easy way to do it?

            QFile file("/home/veriler.txt");
            file.open(QIODevice::WriteOnly | QIODevice::Text);
            QApplication::processEvents();
            QString nktkabul;
            nktkabul= ui->nktKbl->text();
            
            QString mingorv;
            mingorv = ui->minGrv->text();
            
            QTextStream out(&file);
            out<<nktkabul << mingorv;
            
            J Offline
            J Offline
            JonB
            wrote on 11 Feb 2021, 10:41 last edited by
            #5

            @suslucoder said in Double Spin Box Save to the file:

            QApplication::processEvents();

            Remove this.

            But in the future i will have more than 50 lineEdit.

            Set up to use QDataWidgetMapper, which includes moving your data to a model. Or set up an array whose elements point to the data/widgets, so that you can iterate through them. Which is what a QDataWidgetMapper does anyway.

            D 1 Reply Last reply 11 Feb 2021, 11:21
            2
            • J JonB
              11 Feb 2021, 10:41

              @suslucoder said in Double Spin Box Save to the file:

              QApplication::processEvents();

              Remove this.

              But in the future i will have more than 50 lineEdit.

              Set up to use QDataWidgetMapper, which includes moving your data to a model. Or set up an array whose elements point to the data/widgets, so that you can iterate through them. Which is what a QDataWidgetMapper does anyway.

              D Offline
              D Offline
              deleted286
              wrote on 11 Feb 2021, 11:21 last edited by
              #6

              @JonB I have a tab widget with 5 page. Every page contains 20 different line edit and label. Is it possible to do it?

              J 1 Reply Last reply 11 Feb 2021, 11:30
              0
              • D deleted286
                11 Feb 2021, 11:21

                @JonB I have a tab widget with 5 page. Every page contains 20 different line edit and label. Is it possible to do it?

                J Offline
                J Offline
                JonB
                wrote on 11 Feb 2021, 11:30 last edited by
                #7

                @suslucoder said in Double Spin Box Save to the file:

                Is it possible to do it?

                Is it possible to do what?

                The fact that you divide your UI so that the data is presented on separate tabs/pages (which is fine) has nothing to do with whether it is possible to save data, nor whether you might adopt a QDataWidgetMapper approach.

                1 Reply Last reply
                2

                2/7

                10 Feb 2021, 15:17

                topic:navigator.unread, 5
                • Login

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