Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-138648

QSettings (IniFormat) fails to find keys after beginGroup() if subgroups exist

XMLWordPrintable

    • All
    • a6a157101 (dev)

      Unexpected behavior occurs when using QSettings with IniFormat and calling beginGroup() on a group that contains both keys and subgroups. After calling settings.beginGroup("Cars"), a subsequent call to settings.contains("Type") returns false, even though the key exists in the INI file.

      However, if settings.childKeys() or settings.childGroups() is called (e.g., for debugging), the key "Type" is then correctly detected. This issue only manifests when the group contains at least one subgroup.

      Steps to Reproduce:

      1. Open and run the attached example project.
      1. Ensure the test.ini file is located in the same directory as the application binary, or adjust the path if necessary.
      1. Observe the output: the key within the main group is not found using contains().
      1. For comparison, uncomment the debug calls to childKeys() or childGroups() in the example and observe that contains() then correctly detects the key.

      Expected Behavior:
      The contains() method should return true after beginGroup() when the specified key exists, regardless of the presence of subgroups.

      Actual Behavior:
      The contains() method returns false unless childKeys() or childGroups() is called beforehand, which seems to trigger correct parsing.

        For Gerrit Dashboard: QTBUG-138648
        # Subject Branch Project Status CR V

            xavierbesson Xavier Besson
            chakib Chakib Boutaghane
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes