In my program I have a Microsoft's INI style settings/configuration file that is created, edited and stored using the convenient QSettings
class but the user may manually edit this file using the program itself, or any text editor she desires like gedit
or vim
. The order in which key=value pairs appear is important. The problem is whenever I try to store the changes at shutdown time, the order of key=value pairs change to a random order and it seems impossible to stop QSettings
from changing it. For clarification here's a sample of a configuration file:
[AlarmGroup1]
DateTimeNotInitialized=1
DateTimeStampError=2
ParametersMissingOrInconsistent=3
NotInitialized=4
FlashMemoryFatalError=5
NotIdentified=6
which changes to:
[AlarmGroup1]
ParametersMissingOrInconsistent=3
DateTimeNotInitialized=1
DateTimeStampError=2
NotInitialized=4
FlashMemoryFatalError=5
NotIdentified=6
Is it possible to avoid the change of order? Why is Qsettings
behaving like this?
QSettings behaves like this because the problem it was designed to solve was saving/retrieving single key/value pairs, not ordered lists of pairs.
To solve this you will need to either :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With