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. QSettings is not working properly when update the value in the inifile at run time
Qt 6.11 is out! See what's new in the release blog

QSettings is not working properly when update the value in the inifile at run time

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 5 Posters 1.9k 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
    dhu0504
    wrote on last edited by
    #1

    I am using QSettings to read the value from the ini file.
    I am using following code to read the value

    m_cameraConfigSettings->value("GeneralMode/autoexposureenable",readError);

    At first time application is launched it read the value correctly. But When application is running, changed the value in the inifile, and again read the value, the current value having the old value only.
    Any one give the solution for the problem.

    Thanks

    1 Reply Last reply
    0
    • mranger90M Offline
      mranger90M Offline
      mranger90
      wrote on last edited by
      #2

      The doc states that for efficiency the new value may not be written immediately.
      Try calling sync() after setting the new value.

      1 Reply Last reply
      2
      • D Offline
        D Offline
        dhu0504
        wrote on last edited by
        #3

        Actually i am editing manually in the file.
        vi file.ini then update the value

        jsulmJ 1 Reply Last reply
        0
        • D dhu0504

          Actually i am editing manually in the file.
          vi file.ini then update the value

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @dhu0504 So, after editing the config file, do you read the settings again in your app? Because QSettings will not do that for you.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          2
          • D Offline
            D Offline
            dhu0504
            wrote on last edited by
            #5

            Yes. I again read the file using the below command
            m_cameraConfigSettings->value("GeneralMode/autoexposureenable",readError);

            But its given the old value

            jsulmJ JonBJ 2 Replies Last reply
            0
            • D dhu0504

              Yes. I again read the file using the below command
              m_cameraConfigSettings->value("GeneralMode/autoexposureenable",readError);

              But its given the old value

              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by jsulm
              #6

              @dhu0504 Did you actually try to call https://doc.qt.io/qt-5/qsettings.html#sync as @mranger90 already suggested?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              2
              • S Offline
                S Offline
                steverogger007
                wrote on last edited by
                #7
                This post is deleted!
                1 Reply Last reply
                0
                • D dhu0504

                  Yes. I again read the file using the below command
                  m_cameraConfigSettings->value("GeneralMode/autoexposureenable",readError);

                  But its given the old value

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #8

                  @dhu0504
                  As two people have already stated, you must call https://doc.qt.io/qt-5/qsettings.html#sync explicitly if you want to be sure that a change has been written to the external storage file. Period.

                  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