PDA

View Full Version : Read empty groups with QSettings



phenoboy
10th October 2013, 11:55
It seems impossible to read top level group names that are empty.

QSettings s(fileName, QSettings::IniFormat);
s.setIniCodec("UTF-8");

QStringList l2=s.allKeys();
QStringList l=s.childGroups();


INI file:

[0]

[1]

[2]

In this code lists l2 and l are empty. Is there any way to read top level groups that are empty?

ChrisW67
10th October 2013, 21:33
The lists are empty because there are no keys to read in an empty group.

What are you trying to achieve here?

phenoboy
16th October 2013, 09:53
Thanks for you answer.

I'm trying to read top-level group names. In my example I expect the function QSettings::childGropus return a list of 0,1 and 2. I haven't used beginGroup function so I expect childGroups to get group names from top-level of the file.

phenoboy
17th October 2013, 08:15
Should childKeys() return all top-level keys or have I misunderstood something ? It looks like QSettings will discard groups that are empty

wysota
17th October 2013, 08:21
QSettings is about storing settings. If a group has no keys, there is no data in the group thus logically the group might not exist at all. You were asked why you had been trying to access empty groups.