PDA

View Full Version : Using QSettings to read pre-made INI file..



ShaChris23
2nd May 2007, 23:43
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



#
# Configuration file
#

[App]
QueueSize = 10
MaxNrgph = 16384
MaxChNum = 40


[Processor]
ThresholdChNum = 2
Range1 = 10.0
Range2 = 20.0

[Output]
PortNumber = 9000

Brandybuck
3rd May 2007, 05:36
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