QSettings::value() does not return value.
Hello fellow QT devs.
Here goes my problem:
I have QStringList which contains strings of registry paths
i.e.
\Profile Name\Info\Name
\Profile Name\Info\Lenght
\Profile Name\Size\Width
\Profile Name\Size\Height
and so on..
I need to get values from those paths
Code:
...
settings.beginReadArray("Profile Name");
for(int i = 0; i < keys.size(); i++)
{
...
}
...
That's the code I'm trying to use. value() does not return the proper value(no value returned at all!).How can I get the value-function to return the value of that specific key?
Your help is appreciated.
- Eeli Reilin
Re: QSettings::value() does not return value.
Hi,
Quote:
#
QSettings settings;
#
QStringList keys = settings.allKeys();
#
#
settings.beginReadArray("Profile Name");
You are getting the strings from "settings" variable and it has any string yet. Then you insert "Profile Name" to settings and you think that "keys" will auto update the readed value.
Code:
settings.beginReadArray("Profile Name"); //First you have to write the strings
QStringList keys
= settings.
allKeys();
//then you can obtain them
for(int i = 0; i < keys.size(); i++)
{
...
}
Re: QSettings::value() does not return value.
Quote:
Originally Posted by
^NyAw^
Hi,
You are getting the strings from "settings" variable and it has any string yet. Then you insert "Profile Name" to settings and you think that "keys" will auto update the readed value.
Code:
settings.beginReadArray("Profile Name"); //First you have to write the strings
QStringList keys
= settings.
allKeys();
//then you can obtain them
for(int i = 0; i < keys.size(); i++)
{
...
}
Yea, but the values are already in the registry :crying:
value() always returns the default value, which is in my case QVariant::Invalid
Damnit, why is this so damn hard?
- Eeli Reilin
Re: QSettings::value() does not return value.
Quote:
Originally Posted by
zEeLi
Yea, but the values are already in the registry :crying:
value() always returns the default value, which is in my case QVariant::Invalid
Damnit, why is this so damn hard?
The thing is that you do not supply a valid registry path to QSettings constructor... Do you expect it to automagically figure out where your settings are stored? Basically, when you don't pass any parameters to QSettings ctor it does automagically find a location to store them but I doubt it's the one you expect...