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. Optimal way to access QSettings

Optimal way to access QSettings

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 327 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.
  • T Offline
    T Offline
    t0msk
    wrote on last edited by
    #1

    Hello,
    I have applications where I need to work with user defined values (in QSettings) and my application supports dynamically change settings during runtime (using Settings window).

    I would like to ask you what is optimal way to work with QSettings, I know to options:

    • At start load all settings into one object (struct) and use that object for getting values, if I change settings then I save new settings into QSettings and settings object.
    • Everywhere in application I will always get value from QSettings directly.

    Student who loves C/C++

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

      Hi,

      Do you have all settings of your app managed in that
      dialog ?

      How is it designed ?

      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
      • T Offline
        T Offline
        t0msk
        wrote on last edited by
        #3

        Yes all settings are managed in that one settings dialog, on other places across app it is just read-only.

        Student who loves C/C++

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

          One way is to have your settings widget emitting signals to update your other widgets. That way when you load the settings into the settings widget it will propagate to the others. You'll have one central of truth for your application.

          The other possibility is the other way around, each widget is responsible for managing it's own settings and your dialog allows to change them. Store the latest settings on application end for example.

          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
          1
          • T Offline
            T Offline
            t0msk
            wrote on last edited by
            #5

            So something like that settings widget will have public struct which will always contain current settings, and other widgets could read from that struct?

            Student who loves C/C++

            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