PDA

View Full Version : Using Qsettings to read legacy settings format and write it in QSettings format



mstegehu
14th January 2011, 09:18
If have an old program that uses a custom (XML like) format for reading writing settings.

I would like to use the QSettings normal format so I do not have to maintain readers and writers for that format.

So using a custom format I read the settings file and have all my key/value pairs.

Is it possible to use the same QSettings object and set the format to QSettings::NativeIni and write the settings?

QSettings::setDefaultFormat (QSettings::IniFormat); ignores IniFormat and sets the format to the one specified with the creation of the settings object and thus the Custom format that I want to get rid of.

Now I think I have to create a new QSettings object and read/write all values from the old settings object to the new one to be able to save to Ini.

Regards,

Marcel

wysota
14th January 2011, 11:57
Yes, you can't change the backend of an existing object. You have to copy all the data to a new object. QSettings::allKeys() will be helpful.