Results 1 to 2 of 2

Thread: Using QSettings to read pre-made INI file..

  1. #1
    Join Date
    Apr 2007
    Posts
    62
    Thanks
    43
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Using QSettings to read pre-made INI file..

    I have a INI txt file that I want to use with my Qt app. After some googling, I found that QSettings is probably my best bet; I want to use QSettings to read my INI file.

    I then went to QSettings reference page, and read on how to use the class. One thing that I couldnt find was the format that QSettings expects when it reads an INI file.

    Am I using the right class? or QSettings was not meant to be used as just a reader. i.e. when creating an INI file, you need to use QSettings class to create that INI file as well.

    Also, here's the format of my ini file

    Qt Code:
    1. #
    2. # Configuration file
    3. #
    4.  
    5. [App]
    6. QueueSize = 10
    7. MaxNrgph = 16384
    8. MaxChNum = 40
    9.  
    10.  
    11. [Processor]
    12. ThresholdChNum = 2
    13. Range1 = 10.0
    14. Range2 = 20.0
    15.  
    16. [Output]
    17. PortNumber = 9000
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Using QSettings to read pre-made INI file..

    QSettings will work as just a reader. Your format above looks fine to me, but get rid of the spaces before or after the = sign. To be safe, you can use QSettings to generate a sample INI file, then look at it to make sure. I've done a lot of porting from MFC to Qt, and QSettings can read in "standard" Windows INI files just fine.

    p.s. The QSettings doc does talk a little bit about what the format is. See http://doc.trolltech.com/4.2/qsettings.html#Format-enum

  3. The following user says thank you to Brandybuck for this useful post:

    ShaChris23 (3rd May 2007)

Similar Threads

  1. read file from end to beginning..
    By soul_rebel in forum Qt Programming
    Replies: 11
    Last Post: 4th June 2012, 02:20
  2. Replies: 3
    Last Post: 23rd June 2006, 18:46
  3. How to read line from file
    By Krishnacins in forum Newbie
    Replies: 10
    Last Post: 2nd June 2006, 00:14
  4. Replies: 13
    Last Post: 1st June 2006, 15:01
  5. How to read encoding type in XML file
    By danbr in forum Qt Programming
    Replies: 2
    Last Post: 30th April 2006, 09:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.