PDA

View Full Version : QSettings usage for multiple processes



Rohinee
18th November 2019, 05:57
I am planning to use QSettings to save certain parameters of my application. These are to be used for recovery and restoration of the application to the saved state. As I understand from the documentation, the QSettings file can be used across parallel instances of the same application. But for my use case, I will be running parallel instances of the same application, but each application can have a different state which I want to persist. That is, the changes made in one instance should not be propagated to the other instances. Is this possible using QSettings? If so, how?

d_stranz
18th November 2019, 19:26
The default QSettings file format is the same as a Windows INI file, with a hierarchy of key=value fields within groups. If you have a way of giving a unique identifier to each of your parallel processes, then you can define top-level groups using those IDs as the group names. Within each of these top-level groups, you can then have the same subgroup / key-value hierarchy. When any process reads or writes parameters, it must first open the top-level group corresponding to its ID so it gets its own unique set.

I am not sure how you can define unique identifiers for the processes that will be persistent across different invocations. Perhaps there is something on stackoverflow with a solution to this problem.

Rohinee
20th November 2019, 12:00
The default QSettings file format is the same as a Windows INI file, with a hierarchy of key=value fields within groups. If you have a way of giving a unique identifier to each of your parallel processes, then you can define top-level groups using those IDs as the group names. Within each of these top-level groups, you can then have the same subgroup / key-value hierarchy. When any process reads or writes parameters, it must first open the top-level group corresponding to its ID so it gets its own unique set.

I am not sure how you can define unique identifiers for the processes that will be persistent across different invocations. Perhaps there is something on stackoverflow with a solution to this problem.

Thank you! Will try this out.