Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

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

    General and Desktop
    5
    7
    5247
    Loading More Posts
    • 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.
    • U
      umen242 last edited by

      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

      1 Reply Last reply Reply Quote 0
      • D
        DenisKormalev last edited by

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

        1 Reply Last reply Reply Quote 0
        • D
          dangelog last edited by

          There's a nonclosed bold tag somewhere...

          Software Engineer
          KDAB (UK) Ltd., a KDAB Group company

          1 Reply Last reply Reply Quote 0
          • D
            DenisKormalev last edited by

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

            1 Reply Last reply Reply Quote 0
            • R
              rokemoon last edited by

              Why is all text bold?

              1 Reply Last reply Reply Quote 0
              • D
                dangelog last edited by

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

                Software Engineer
                KDAB (UK) Ltd., a KDAB Group company

                1 Reply Last reply Reply Quote 0
                • G
                  giesbert last edited by

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

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post