Hi...
Is there with Qt something to read easily text file with Windows .ini style ?!?
Like this:
Qt Code:
[GROUP 1] key1 = value1 key2 = value2 [GROUP 2] key1 = value1 ....To copy to clipboard, switch view to plain text mode
Thanks
Hi...
Is there with Qt something to read easily text file with Windows .ini style ?!?
Like this:
Qt Code:
[GROUP 1] key1 = value1 key2 = value2 [GROUP 2] key1 = value1 ....To copy to clipboard, switch view to plain text mode
Thanks
Hi,
You can use QSettings :
QSettings::QSettings ( const QString & fileName, Format format, QObject * parent = 0 )
Fred.
Please not that QSettings only properly reads INI files that were also created with QSettings. You might be lucky to read other INI files too, but it is not guaranteed.
Disclaimer: Although I work on Qt for Nokia, anything I post here is personal
Ok...but If I want to parse with Qt an existing INI file like this:
Qt Code:
[TOP_LEFT] [ELEMENT1] comment = Name tag = Cliente_Name sequence = 1 Modality = all [ELEMENT2] comment = Birth_Date tag = Client_Birth_Date sequence = 2 Modality = all [TOP_CENTER] [ELEMENT 1] comment = example tag = example sequence = 1 Modality = all [ELEMENT 2] comment = example2 tag = example2 sequence = 2 Modality = all [TOP] value = proveTo copy to clipboard, switch view to plain text mode
I've try with QSettings and childGroups() but it doesn't works...
Which is the better way to do this?
Thanks
As far as I know this is not a proper "ini" file. For the above mentioned file I'd use regexps.
Sorry...but with RegExp how can you pass the text file?!
If you have to use this format of ini file, why not change it to XML file?
You parse it line by line and decide what to do with the result afterwards. For instance if you know the line is like "\[([A-Za-z0-9_]+)\]" then you know it is a (sub)group so you can create a group node in your final structure. If the line is like "([A-Za-z0-9_]+) = (.*)" then you know it is an item and you can create an item node in your final structure.
Bookmarks