Results 1 to 12 of 12

Thread: reading from registry

  1. #1
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question reading from registry

    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.
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: reading from registry

    Where is the problem?
    Just use QSettings again to read the keys you stored...
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. The following user says thank you to high_flyer for this useful post:

    phillip_Qt (25th October 2007)

  4. #3
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: reading from registry

    Quote Originally Posted by high_flyer View Post
    Where is the problem?
    Just use QSettings again to read the keys you stored...

    But my doubt is how to do that?
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

  5. #4
    Join Date
    Jun 2006
    Posts
    32
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: reading from registry

    QSettings.readValue

  6. #5
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: reading from registry

    Quote Originally Posted by Equilibrium View Post
    QSettings.readValue
    But in QSetting there is no member function like readValue();
    Can u plz give me a sample of code.?
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

  7. #6
    Join Date
    Oct 2007
    Location
    Munich, Bavaria
    Posts
    144
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Exclamation Re: reading from registry

    QVariant value ( const QString & key, const QVariant & defaultValue = QVariant() ) const

  8. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: reading from registry

    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.

  9. #8
    Join Date
    Oct 2007
    Location
    Munich, Bavaria
    Posts
    144
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Smile Re: reading from registry

    Quote Originally Posted by wysota View Post
    ...

    @DeepDiver: Oh come on... this way he won't learn anything.
    Okay - here is my adjusted post:

    RTFM


  10. #9
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Unhappy Re: reading from registry

    Quote Originally Posted by wysota View Post
    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"
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

  11. #10
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: reading from registry

    could you show us where in your code you use 'readEntry'?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  12. #11
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: reading from registry

    Quote Originally Posted by phillip_Qt View Post
    QString str = settings.value(keyname, subkeyname).toString();
    Excuse me, but what's "subkey"? If you take a look at the docs (<-- this is a link, make sure to follow it), you'll see that the second parameter is default value, not any subkey.
    J-P Nurmi

  13. #12
    Join Date
    Oct 2007
    Posts
    201
    Thanks
    19
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile Re: reading from registry

    Quote Originally Posted by jpn View Post
    Excuse me, but what's "subkey"? If you take a look at the docs (<-- 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.
    Cheers,
    Phillip



    --- Please post the solution you got to solve your problem. It may help others.

Similar Threads

  1. QWT 5, QT3, SuSE 10.2. Crash and burn
    By DrMcCleod in forum Qwt
    Replies: 8
    Last Post: 7th September 2007, 20:53
  2. Function for reading and writing
    By merry in forum Newbie
    Replies: 2
    Last Post: 30th May 2007, 08:30
  3. Server not reading
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 7th December 2006, 14:45
  4. QDataStream reading into QString
    By jakamph in forum Qt Programming
    Replies: 4
    Last Post: 15th October 2006, 09:22
  5. Replies: 2
    Last Post: 4th May 2006, 19:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.