QSettings how to save QMap<QString,int> into configuration file



  • currently im saving simple values into configuration file , but now i have QMap<QString ,int>
    struct that i like to map into configuration file.
    so if my QMap look like this:
    "11111",1
    "22222",1
    "4444,0
    in my configuration it will look like this:

    [my gui config]
    11111=1
    22222=1
    4444=0

    and also how to ready it back to the same QMap struct



  • Write them with
    @
    foreach (const QString &key;, map.keys()) {
    settings.setValue(key, map[key]);
    }
    @
    and read them back with
    @
    QStringList QSettings::allKeys () const
    @



  • There's a nonclosed bold tag somewhere...



  • peppe, yeah, it happens sometimes and fyi there is no bold tag in first post source. Marius or Gurudutt should look here.



  • Why is all text bold?



  • The thread's title is not HTML-escaped. Thus the <> symbols in the template break things.



  • [quote author="peppe" date="1312109506"]The thread's title is not HTML-escaped. Thus the <> symbols in the template break things.[/quote]

    That was the problem, I replaced the tags by the HTML escape sequences now...


Log in to reply
 

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