Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Saving dial value
Qt 6.12 LTS is out! See what's new in the release blog

Saving dial value

Scheduled Pinned Locked Moved Solved General and Desktop
21 Posts 3 Posters 12.5k 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.
  • ? A Former User

    @mrjj

    "aKey" is a mandatory paramater ? and the reference mentions that:

    When creating a QSettings object, you must pass the name of your company or organization as well as the name of your application. For example, if your product is called Star Runner and your company is called MySoft, you would construct the QSettings object as follows:
    
        QSettings settings("MySoft", "Star Runner");
    

    Is this mandatory ? what if , if i dont have any company ? :)

    mrjjM Offline
    mrjjM Offline
    mrjj
    Lifetime Qt Champion
    wrote on last edited by
    #12

    @rapid84
    hi
    the akey is the name of the value. It saves to registry so that why it needs a name
    For you , it could be slidervalue or something that explains what u save.

    You can use anything u like for company. Its also because its store in registry.
    So just use some name u like that IS not a real company. :)

    ? 1 Reply Last reply
    0
    • mrjjM mrjj

      @rapid84
      hi
      the akey is the name of the value. It saves to registry so that why it needs a name
      For you , it could be slidervalue or something that explains what u save.

      You can use anything u like for company. Its also because its store in registry.
      So just use some name u like that IS not a real company. :)

      ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #13

      @mrjj

      For loading i use;

       QSettings settings("settingName");
          int  aValue=settings.value("aKey").toInt();
          int  aValue2=settings.value("aKey2").toInt();
          ui->dial->setValue(aValue);
          ui->dial_2->setValue(aValue2);
      

      and for saving i use

      QSettings settings("settingName");
          int somevalue = ui->dial->value();
          int somevalue2 = ui->dial_2->value();
          settings.setValue("aKey",somevalue);
          settings.setValue("aKey2",somevalue2);
      

      These work for me , thanks for help. by the way, in a debian OS , where do it save ( in which directory)?

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

        Hi
        That is good question :)
        try
        qDebug() << settings.fileName();

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

          If I may suggest one improvement is to use a better name than
          "aKey" and "aKey2"
          Maybe Dial1Value and Dial2Value

          ? 1 Reply Last reply
          0
          • mrjjM mrjj

            If I may suggest one improvement is to use a better name than
            "aKey" and "aKey2"
            Maybe Dial1Value and Dial2Value

            ? Offline
            ? Offline
            A Former User
            wrote on last edited by A Former User
            #16

            @mrjj

            when i click the close button, while it is saving data , it waits sometime and close with a 1-2 seconds delay. Is this normal ?

            mrjjM 1 Reply Last reply
            0
            • ? A Former User

              @mrjj

              when i click the close button, while it is saving data , it waits sometime and close with a 1-2 seconds delay. Is this normal ?

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #17

              @rapid84
              Normally it saves really fast so i never noticed it.

              ? 1 Reply Last reply
              0
              • mrjjM mrjj

                @rapid84
                Normally it saves really fast so i never noticed it.

                ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #18

                @mrjj
                on raspbian sometimes it takes up to 5 -6 seconds to store the data. i have tested it, maybe i will need to use QFile.

                mrjjM 1 Reply Last reply
                0
                • ? A Former User

                  @mrjj
                  on raspbian sometimes it takes up to 5 -6 seconds to store the data. i have tested it, maybe i will need to use QFile.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #19

                  @rapid84
                  ok. thats pretty long.
                  It must have a reason.
                  QFile should be faster.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #20

                    Hi,

                    You shouldn't need to but you can try adding a call to sync in order to flush the content of your settings to the disk.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #21

                      @mrjj @SGaist
                      hi
                      i am using QFile now and it works clearly for me. Thanks.

                      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
                      • Unsolved