Results 1 to 2 of 2

Thread: QSettings: copy from ini to xml? Copy group?

  1. #1
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Thanks
    62
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QSettings: copy from ini to xml? Copy group?

    I have rather complicated QSettings-based confuguration file, that grew by time and became quite large. Originally I selected "ini" format, which in the hindsight appears to be a wrong choice. Now I have to move the configuration to the website where there is no Qt.

    My questions are:
    1. Is there an easy way to copy a "group" (created with "beginGroup/endGroup" calls) to a new group in the same QSetting-based config file?
    Something like non-existent QSetting::copyGroup("currentName", "newName"), so everything iside the group is copied?

    2. Is there a way to copy one configuration file format into another? I have an .ini-based config and would like to convert it to xml. Doing it programmatically group by group will be a tedious work. Any converters out there?

    Suggestions and comments will be appreciated.

    Thanks.

  2. #2
    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: QSettings: copy from ini to xml? Copy group?

    Quote Originally Posted by TorAn View Post
    1. Is there an easy way to copy a "group" (created with "beginGroup/endGroup" calls) to a new group in the same QSetting-based config file?
    Something like non-existent QSetting::copyGroup("currentName", "newName"), so everything iside the group is copied?
    Yes. QSettings::childKeys() returns all the keys in the current group. You can iterate over them and copy the contents elsewhere.

    2. Is there a way to copy one configuration file format into another? I have an .ini-based config and would like to convert it to xml. Doing it programmatically group by group will be a tedious work. Any converters out there?
    Sure. Implement an XML backend for QSettings (see QSettings::registerFormat) then open the ini-based settings, use QSettings::allKeys() to get all the keys in the settings and insert the key-value pairs into the xml-based settings.
    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.


  3. The following user says thank you to wysota for this useful post:

    TorAn (12th January 2012)

Similar Threads

  1. Replies: 1
    Last Post: 24th June 2011, 11:11
  2. Replies: 2
    Last Post: 1st March 2011, 17:00
  3. QSettings and colons in group name
    By anthon in forum Qt Programming
    Replies: 1
    Last Post: 15th August 2010, 18:01
  4. extra hard copy (as text) of QSettings
    By navid in forum Newbie
    Replies: 5
    Last Post: 5th December 2009, 14:05
  5. Replies: 1
    Last Post: 23rd January 2007, 07:46

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.