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 : custom ini file
Forum Updated to NodeBB v4.3 + New Features

QSettings : custom ini file

Scheduled Pinned Locked Moved General and Desktop
7 Posts 4 Posters 3.8k 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.
  • E Offline
    E Offline
    evergreen
    wrote on last edited by
    #1

    Hello,

    I'm on Windows XP.

    I'm using Qsettings in order to save properties. Those properties has different types (int, QSTring, bool...). When I use a classical QSettings that is basically stored on windows registered, no problem. But when i try to use an INI file, the types of settings ar lost (that's any ascii file so only char).
    I would like to know if it's possible to custom this file in order to give the type of each dtata stored in it.

    Thanks

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gedd
      wrote on last edited by
      #2

      An ini file is a text file so you can just get string.
      You use QString functions

      @toDouble ( )
      toFloat ()
      toInt ( )
      toLong ( )
      toLower ()
      toShort ( )@
      ...
      for number

      or for boolean

      @bool mybool = (myString=="true")?true:false;@

      etc ...

      Gedd

      1 Reply Last reply
      0
      • E Offline
        E Offline
        evergreen
        wrote on last edited by
        #3

        That means I can't know the type of data I put into it I guess....

        1 Reply Last reply
        0
        • G Offline
          G Offline
          gedd
          wrote on last edited by
          #4

          I hope you know the type of data you put into
          That means also that string is type of string and nothing else.

          Try to use group (aka the 'key' in QSettings i think)

          [MyInt]
          ...

          [MyFloat]
          ...

          Gedd

          1 Reply Last reply
          0
          • E Offline
            E Offline
            evergreen
            wrote on last edited by
            #5

            That's an intersting idea. I already use the arborescence but it could be usefull.
            Anyway, after 4 hours looking for a solution about the ini file, if anyone gets the same idea I got, it doesn't seam possible to modify its protocol to put the type into it.

            I'll check on give this informations by the groups or write my own writing function.

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Peppy
              wrote on last edited by
              #6

              You should use class named "QVariant":http://doc.trolltech.com/4.7/qvariant.html

              For example:
              @QVariant("DEAD").convert(QVariant::Int);@

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #7

                ini files work without problems for me. You'll have to use QSettings setValue and value methods.

                http://www.catb.org/~esr/faqs/smart-questions.html

                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