How to read INI file
-
Is it possible to read ini file with duplicates keys using QSettings?
[secret]
shard=/app/key/shard0.pem
shard=/app/key/shard1.pem
shard=/app/key/shard2.pem
shard=/app/key/shard3.pem
shard=/app/key/shard4.pemI can not change ini file because it's part of another program.
-
-
@DimaSsS QSettings isn't meant to do that. If you assign multiple values to the same key, the entry is overwritten.
From QSettings point of view your ini file is faulty and it just happens to work out, that one entry is read anyway.
You will have to parse that file yourself
-
@DimaSsS
If you do go down the route of parsing that file yourself, it looks like you could use QSettings::Format QSettings::registerFormat() supplying your own QSettings::ReadFunc so as to end up successfully interoperating withQSettings
if you want that. -
You should see the following video about QSettings class and how to read config file like .INI File in Qt Application
Read And Write in INI File : https://www.youtube.com/watch?v=62Mzbt8QqLE
Read And Write in Registry : https://www.youtube.com/watch?v=1v_oDXDhKgg
-
@Ketan__Patel__0011
This is general video about usingQSettings
. It has nothing to say about the OP's question of handling duplicate keys. -
@Ketan__Patel__0011
:) OK. This thread is asking about a particular problem, "duplicate keys", which I don't thinkQSettings
will handle as the OP wishes.