QSettings problem in windows
I have a program in windows platform ...........
I have just made up a registry like this....
chow
kurra
Settings
in the Settings key i have some string values like say "showDialogOnPrinting" which data is not set...
Now in my program i set my organisationName to chow
and my application name to kurra
and Code like this....
Code:
settings.beginGroup("Settings");
bool shDialog = settings.value("showDialogOnPrinting",false);
checkboxShDialog->setChecked(shDialog);
here the settings.value("showDialogOnPrinting",false); is supposed to set false if there is no value(According to docs the false in this case is the default/fallback value).
But that didnt set false in the registry....and the code was successfully executed..
when i change the value to true in the registry, it works good,it fetches the true and checks the box....
Re: QSettings problem in windows
Quote:
But that didnt set false in the registry....and the code was successfully executed..
It will not set the value in registry, it will return false if there is no such key in your settings, or it's value is not convertible to bool. So the variable shDialog will be true/false depending on the value in settings. Reading values from settings will not change the registry.
In order to set a value in registry you need to use
Code:
bool b = ...;
...
settings.beginGroup("Settings");
settings.setValue("showDialogOnPrinting",b);
Re: QSettings problem in windows
HI,
try using QVariant::toBool() when you reading value.
Code:
settings.beginGroup("Settings");
bool shDialog = settings.value("showDialogOnPrinting",false).toBool();
checkboxShDialog->setChecked(shDialog);