PDA

View Full Version : reading from registry



phillip_Qt
25th October 2007, 10:21
Hi All,
actually my problem is that ive stored some string values in registry by using setValue.
QSettings settings("MY DATA","setvalue");
settings.setValue("my value","my value 10");
settings.setValue("your value","your value 20");

i need 2 retrive my value 10 and your value 10 and to collect it in QString. can any body help me?
Thank You All.

high_flyer
25th October 2007, 10:44
Where is the problem?
Just use QSettings again to read the keys you stored...

phillip_Qt
25th October 2007, 10:47
Where is the problem?
Just use QSettings again to read the keys you stored...


But my doubt is how to do that?

Equilibrium
25th October 2007, 10:48
QSettings.readValue

phillip_Qt
25th October 2007, 10:51
QSettings.readValue
But in QSetting there is no member function like readValue();
Can u plz give me a sample of code.?

DeepDiver
25th October 2007, 10:53
QVariant value ( const QString & key, const QVariant & defaultValue = QVariant() ) const

wysota
25th October 2007, 10:55
Why don't you take a look at QSettings docs and see if there is a method that has a name which suggests it fetches a value from the dataset... I assure you it's obvious.

@DeepDiver: Oh come on... this way he won't learn anything.

DeepDiver
25th October 2007, 11:11
...

@DeepDiver: Oh come on... this way he won't learn anything.

Okay - here is my adjusted post:

RTFM

:D

phillip_Qt
25th October 2007, 12:15
Why don't you take a look at QSettings docs and see if there is a method that has a name which suggests it fetches a value from the dataset... I assure you it's obvious.

@DeepDiver: Oh come on... this way he won't learn anything.

i Tried like this
QSettings settings;
bool ok = settings.contains(keyname);
QString str = settings.value(keyname, subkeyname).toString();
and i ve defined keyname, subkeyname as a macro in a .h file.
but now its giving compilation error "'class QSettings' has no member named 'readEntry"

high_flyer
25th October 2007, 12:17
could you show us where in your code you use 'readEntry'?

jpn
25th October 2007, 12:45
QString str = settings.value(keyname, subkeyname).toString();
Excuse me, but what's "subkey"? If you take a look at the docs (http://doc.trolltech.com/latest/qsettings.html#value) (<-- this is a link, make sure to follow it), you'll see that the second parameter is default value, not any subkey.

phillip_Qt
26th October 2007, 06:49
Excuse me, but what's "subkey"? If you take a look at the docs (http://doc.trolltech.com/latest/qsettings.html#value) (<-- this is a link, make sure to follow it), you'll see that the second parameter is default value, not any subkey.
Ok. thanks for correcting my fault.