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. QSettings how to save QMap<QString,int> into configuration file
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
7 Posts 5 Posters 5.5k Views
  • 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 Offline
    U Offline
    umen242
    wrote on last edited by
    #1

    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
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      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
      0
      • D Offline
        D Offline
        dangelog
        wrote on last edited by
        #3

        There's a nonclosed bold tag somewhere...

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

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DenisKormalev
          wrote on last edited by
          #4

          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
          0
          • R Offline
            R Offline
            rokemoon
            wrote on last edited by
            #5

            Why is all text bold?

            1 Reply Last reply
            0
            • D Offline
              D Offline
              dangelog
              wrote on last edited by
              #6

              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
              0
              • G Offline
                G Offline
                giesbert
                wrote on last edited by
                #7

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

                • Login

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