PDA

View Full Version : QSettings to read .plist on Mac



lemmiwinks
3rd February 2010, 13:44
Hello everyone,
I've been fighting for a few days with QSettings on QT4.6 and haven't been able to figure out what's wrong so thought I'd post here and hopefully find some help :)

I have a .plist file, created by another program, than I need to read inside my own QT application.
Here's what I'm doing:


QSettings zwoptexList(fileName,QSettings::NativeFormat);
QStringList keys = zwoptexList.allKeys();
for (int i = 0; i < keys.size(); i++) {
QString tempString = keys.at(i);
qDebug() << tempString;
}

And this is how the .plist file is structured (part of it, it's just a standard .plist file that works fine):


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>frames</key>
<dict>
<key>earth_edge02.png</key>
<dict>
<key>height</key>
<integer>64</integer>
<key>offsetX</key>
<real>-9</real>
.....
</dict>
<key>earth_top01.png</key>
<dict>
<key>height</key>
<integer>32</integer>
....
</dict>
....
</dict>
</plist>


So I'm just trying to print out all the keys so far to be sure of what's going on.
The results are different if I use:
allKeys();
childKeys();
childGroups();

if I use allKeys(), I get the value "frames", which is the highest key in the .plist of type "Dictionary", and nothing else.
By my understanding that should be seen as a group by QSettings, but it sees it as normal key, I tried calling beginGroup("frames"); but I just can't seem to access the keys inside this group.

If I call childGroups() I get no values, I haven't found any ways to access groups or make them seem as such.

Could someone please try and help me understand what I'm doing wrong?
Thanks very much for any insight,
Patrick

franz
3rd February 2010, 21:13
After I'd have checked and checked again the filename, I would probably make a small Qt app that generates a plist with the exact same contents you expect it to contain and then look at the diff of the file, just to check if there were any differences in interpretation. Either of them could be reading or writing the plist incorrectly. QSettings should be able to work with its own output, so if there are no obvious differences, there is something else going on.

Obviously you've tried it with different files as well, so I think you already checked the filename a few times. Try writing the comparison.