Results 1 to 2 of 2

Thread: QSettings to read .plist on Mac

  1. #1

    Default QSettings to read .plist on Mac

    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:
    Qt Code:
    1. QSettings zwoptexList(fileName,QSettings::NativeFormat);
    2. QStringList keys = zwoptexList.allKeys();
    3. for (int i = 0; i < keys.size(); i++) {
    4. QString tempString = keys.at(i);
    5. qDebug() << tempString;
    6. }
    To copy to clipboard, switch view to plain text mode 
    And this is how the .plist file is structured (part of it, it's just a standard .plist file that works fine):
    Qt Code:
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    3. <plist version="1.0">
    4. <dict>
    5. <key>frames</key>
    6. <dict>
    7. <key>earth_edge02.png</key>
    8. <dict>
    9. <key>height</key>
    10. <integer>64</integer>
    11. <key>offsetX</key>
    12. <real>-9</real>
    13. .....
    14. </dict>
    15. <key>earth_top01.png</key>
    16. <dict>
    17. <key>height</key>
    18. <integer>32</integer>
    19. ....
    20. </dict>
    21. ....
    22. </dict>
    23. </plist>
    To copy to clipboard, switch view to plain text mode 

    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

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSettings to read .plist on Mac

    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.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

Similar Threads

  1. How to use QSettings to read INI file
    By Cantora in forum Newbie
    Replies: 8
    Last Post: 16th June 2011, 09:14
  2. Replies: 2
    Last Post: 2nd September 2009, 14:36
  3. Replies: 1
    Last Post: 19th September 2008, 16:43
  4. QSettings , read only avaiable?
    By patrik08 in forum Qt Programming
    Replies: 5
    Last Post: 18th November 2007, 16:21
  5. Using QSettings to read pre-made INI file..
    By ShaChris23 in forum Newbie
    Replies: 1
    Last Post: 3rd May 2007, 06:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.