Results 1 to 5 of 5

Thread: Read empty groups with QSettings

  1. #1
    Join Date
    Jun 2012
    Posts
    63
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Read empty groups with QSettings

    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?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Read empty groups with QSettings

    The lists are empty because there are no keys to read in an empty group.

    What are you trying to achieve here?

  3. #3
    Join Date
    Jun 2012
    Posts
    63
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Read empty groups with QSettings

    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.

  4. #4
    Join Date
    Jun 2012
    Posts
    63
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Read empty groups with QSettings

    Should childKeys() return all top-level keys or have I misunderstood something ? It looks like QSettings will discard groups that are empty
    Last edited by phenoboy; 17th October 2013 at 08:23.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Read empty groups with QSettings

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Read Several Groups in INI file from QSettings
    By deepal_de in forum Qt Programming
    Replies: 3
    Last Post: 5th July 2011, 09:43
  2. How to use QSettings to read INI file
    By Cantora in forum Newbie
    Replies: 8
    Last Post: 16th June 2011, 08:14
  3. Replies: 1
    Last Post: 14th January 2011, 11:57
  4. QSettings to read .plist on Mac
    By lemmiwinks in forum Qt Programming
    Replies: 1
    Last Post: 3rd February 2010, 21:13
  5. Replies: 3
    Last Post: 20th November 2009, 14:32

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.