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. qt settings file issue
Forum Updated to NodeBB v4.3 + New Features

qt settings file issue

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 523 Views 4 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.
  • ademmlerA Offline
    ademmlerA Offline
    ademmler
    wrote on last edited by
    #1

    Hi,

    I found an possible issue with QSettings:
    Here are the part from my code:

    QSettings settings(settingsFile, QSettings::IniFormat);
    rgbProfile = QString(settings.value("cmm/profile_rgb", "ProPhoto.icm").toString()).toStdString();
    

    I would expect, that if the entry "cmm/profile_rgb" is empty or missing I get "ProPhoto.icm" as default value.
    But this happens only if the entry is fully missing!
    If the entry ist there but empty like this - I get an empty value for rgbProfile:

    [cmm]
    profile_rgb=
    

    Is there an option to change behavior of QSettings or can you confirm this a bug?

    thx and regards
    Alex

    1 Reply Last reply
    0
    • ademmlerA ademmler

      thx guys for your input. I may ask more precise:

      Is there an QT Option to define the behavior?
      Like "Qt:TakeDefaultIfKeyIsEmpty" or "Qt:TakeAlwaysValue" ...

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

      @ademmler
      Hi
      Nope. If the key exists, it will return its value. even if it's an empty one.

      ademmlerA 1 Reply Last reply
      2
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Ini format is not very well defined and behaviors differ a lot between different parsers, especially when it comes to white space treatment.

        Having said that I wouldn't consider this a bug. The default parameter is only used when the key is not found. If it is the value is considered present, even if it's an empty one. An empty value can be a useful thing. For example it can be used to store empty strings, which in some cases can be a valid value for a key and shouldn't be replaced by defaults.

        As far as I know there's no built in mechanism to change that behavior of QSettings ini parsing, so just add an extra check for the empty values if you want it that way.

        1 Reply Last reply
        4
        • Kent-DorfmanK Offline
          Kent-DorfmanK Offline
          Kent-Dorfman
          wrote on last edited by
          #3

          I would concur with @Chris-Kawa in that it's not a bug or a "bad behaviour". The key exists and has a null value. That is a case worth checking for. Simply absorb the overhead of comparing the result against a null string and react accordingly.

          I light my way forward with the fires of all the bridges I've burned behind me.

          1 Reply Last reply
          1
          • ademmlerA Offline
            ademmlerA Offline
            ademmler
            wrote on last edited by
            #4

            thx guys for your input. I may ask more precise:

            Is there an QT Option to define the behavior?
            Like "Qt:TakeDefaultIfKeyIsEmpty" or "Qt:TakeAlwaysValue" ...

            mrjjM 1 Reply Last reply
            0
            • ademmlerA ademmler

              thx guys for your input. I may ask more precise:

              Is there an QT Option to define the behavior?
              Like "Qt:TakeDefaultIfKeyIsEmpty" or "Qt:TakeAlwaysValue" ...

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

              @ademmler
              Hi
              Nope. If the key exists, it will return its value. even if it's an empty one.

              ademmlerA 1 Reply Last reply
              2
              • mrjjM mrjj

                @ademmler
                Hi
                Nope. If the key exists, it will return its value. even if it's an empty one.

                ademmlerA Offline
                ademmlerA Offline
                ademmler
                wrote on last edited by
                #6

                @mrjj thx for making this clear!

                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