Does QSettings Group check for redundant posts?



  • Okay, after going over my code again, I think I have it figured out now. However, I came upon something else. Does QSettings check for multiple posts automatically or do I have to use a compare operator?


  • Lifetime Qt Champion

    Hi,

    What do you mean by multiple posts ?



  • What I want to do is have something be compared inside a QSettings group, and if it is\isn't there, do something.



  • If you just want to check whether a specif key is already set, simply use:
    bool QSettings::contains ( const QString & key ) const

    If your key is inside a group, then either use beginGroup() before contains() or specify the key as "myGroupName/myKeyName".

    Maybe you could also use QSettings::value() with an appropriate default value...



  • [quote author="MuldeR" date="1366396739"]If you just want to check whether a specif key is already set, simply use:
    bool QSettings::contains ( const QString & key ) const

    If your key is inside a group, then either use beginGroup() before contains() or specify the key as "myGroupName/myKeyName".

    Maybe you could also use QSettings::value() with an appropriate default value...[/quote]

    Oh I checked the documentation with that and saw it there. Crap, how did I not see it. Thanks for showing me though.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.