[SOLVED]-Problems with QSettings output to INI format. Colons don't write correctly.

  • I am using Qt 5.0.2 on Windows 7 and Mac OSX.

    I use an INI file for storing application settings and I use colons as tokens in my keys like this.


    This is just an example but I think yu get the idea.

    When I write this using the QSettings class I get a strange result in the ini file.

    QSettings settings("MySettings.ini",QSettings::IniFormat);
    settings.setValue("Values/value::integer", 1);
    settings.setValue("Values/value::real", 2.5);
    settings.setValue("Values/value::special::one", "Special_One");

    The resulting colons are written as the character codes "<percent>3A" in the INI file not as the actual characters. I can't show you that here because the browser will just interpret the code and display the colons correctly. Please try the code above and you can see what happens.

    This is not what I want. Is this normal or is it a bug. I don't see any mention in the documentation about such behaviour.

    Does anyone now what is going on here and how I can make it output the colons correctly. If it looks like it is a bug I will report.

    Many thanks.

  • Moderators

    i believe that's implemented in the Qt sources this way and can't be changed (i might be wrong though).
    But you can use "QSettings::registerFormat()":http://qt-project.org/doc/qt-5.0/qtcore/qsettings.html#registerFormat and write it yourself. Shouldn't be that big of work...

  • Thanks for your comment raven-worx.

    I will look at how I might do that then.
    So do you know the rational behind implementing in this way? I am just curious.


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.