Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. static function and qsettings
Qt 6.12 LTS is out! See what's new in the release blog

static function and qsettings

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

    in my app, in one class i save some settings using QSetting. in another class i have a static member and a static setter function for it which i call in the constructor of this latter class (that has this static member). however, i set the value based on a setting read from the other class i mentioned above. can i be sure that the setting was read before i'm setting the value with the static function? or how can i ensure that?

    K 1 Reply Last reply
    0
    • U user4592357

      in my app, in one class i save some settings using QSetting. in another class i have a static member and a static setter function for it which i call in the constructor of this latter class (that has this static member). however, i set the value based on a setting read from the other class i mentioned above. can i be sure that the setting was read before i'm setting the value with the static function? or how can i ensure that?

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @user4592357

      Did you use QSettings sync?

      Vote the answer(s) that helped you to solve your issue(s)

      U 1 Reply Last reply
      0
      • K koahnig

        @user4592357

        Did you use QSettings sync?

        U Offline
        U Offline
        user4592357
        wrote on last edited by
        #3

        @koahnig

        no i didn't use that. the docs says it's called automatically so why do i need to call it? should i, anyways?

        K 1 Reply Last reply
        0
        • U user4592357

          @koahnig

          no i didn't use that. the docs says it's called automatically so why do i need to call it? should i, anyways?

          K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          @user4592357

          It actually says:
          This function is called automatically from QSettings's destructor and by the event loop at regular intervals, so you normally don't need to call it yourself.

          Therefore, I would suggest to call it. It will not hurt.

          If the destructor is actually called in your case, you are the only one able to answer. The case with the regular calls by the event loop leaves evetuallities open, but the intetional call will make sure that the routine is called.

          Vote the answer(s) that helped you to solve your issue(s)

          U 1 Reply Last reply
          0
          • K koahnig

            @user4592357

            It actually says:
            This function is called automatically from QSettings's destructor and by the event loop at regular intervals, so you normally don't need to call it yourself.

            Therefore, I would suggest to call it. It will not hurt.

            If the destructor is actually called in your case, you are the only one able to answer. The case with the regular calls by the event loop leaves evetuallities open, but the intetional call will make sure that the routine is called.

            U Offline
            U Offline
            user4592357
            wrote on last edited by
            #5

            @koahnig

            okay, i got it, i'll call it. so, that will ensure that settings are loaded before calling the static function?

            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