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.
-
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
Have you tried it?
My guess would be that the last line overrides the earlier ones, you end up withshard
having value/app/key/shard4.pem
? -
@JonB Yes
i tried to use allKeys() and childKKeys() and its returns me only shard=/app/key/shard4.pem
but i need all shards and save them into QStringList:( -
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
-
@JonB Yes
i tried to use allKeys() and childKKeys() and its returns me only shard=/app/key/shard4.pem
but i need all shards and save them into QStringList:(@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
-
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
This is general video about usingQSettings
. It has nothing to say about the OP's question of handling duplicate keys.@JonB
Actually i Did not read the whole thread.
i just read the Title of thread and share something according it. -
@JonB
Actually i Did not read the whole thread.
i just read the Title of thread and share something according it.@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.