[SOLVED]Read multiple files using QSettings?
-
You can't do that, you will only damage your data this way. Construct a new QSettings object (put it on a stack within the loop) for every file.
@
for (some; conditions; blah) {
QSettings settings(path);
// ...
}
@ -
Why?
We use a multiple-configuration store solution, but it doesn't work using QSettings to read multiple files using a loop...
Instead, we basically have a class that is our central settings interface in the application. That class decides per setting which of the underlying settings files (or registry) it will use for what setting, and who overrules who.
-
I had an unknown number of files that I needed to read and parse. In any case I had to do something like
for (some; conditions; blah) {
QSettings* settings = new QSettings(path);
// ...
}in order to pass the settings object to the function responsible for saving stuff, I hope it is not a stupid move :)
Thanks.
-
Hey Andre,
the thing with me though is that I have many files, each one with its' respective settings file, so I decided to read all those files and save them in a list structure. Not sure if its the smartest thing to do :P
EDIT:
Yes I do call settings.clear(); on every loop -
In that case, why not create the instance on the stack in the first place?
@
for (some; conditions; blah) {
QSetting settings(path);
theProcessingFunction(&setting); // if you must use a pointer, a (const) reference would probably be better
}
@That's more efficient and less error phrone.