Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED]-Problems with QSettings output to INI format. Colons don't write correctly.
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kenchan
    wrote on last edited by
    #1

    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.

    [Values]
    value::integer=1
    value::real=2.5
    value::special::one=Special_One
    ...

    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.

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      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...

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • K Offline
        K Offline
        kenchan
        wrote on last edited by
        #3

        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.

        Thanks

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved