[Interest] QWidget + friends; How to restore properties across sessions?
Christoph Feck
christoph at maxiom.de
Sat Aug 16 10:37:27 CEST 2014
On Friday 15 August 2014 21:48:08 Mark Gaiser wrote:
> Now i'm searching for alternatives to this approach to prevent
> handling the bookkeeping myself and still have the same result. For
> instance, would it be possible to have some function (in QObject or
> QWidget i guess) where you either:
> - Define which properties should be saved/restored across sessions,
> bookkeeping would be done internaly.
> - or just some "QObject::persistentSettings(bool)" function that -
> when true - saves any properties and restores them upon next
> request in a persistent manner.
Each QMetaObject has a userProperty() which identifies the value that
the user can change in the object. To get a key for the settings file,
you can use special objectName()s. For example, in Smaragd, I prefix
any object that should have a persistent user property with "cm_" (for
config manager). See code at [1].
In Skulpture, there are two older versions of this file, one of them
uses QSettings[2] instead of KConfigGroup[3]. Those additionally
handle oddities with combo boxes, but they do not use userProperty().
[1]
https://projects.kde.org/projects/playground/artwork/smaragd/repository/revisions/master/entry/src/config/configmanager.h
[2]
http://quickgit.kde.org/?p=scratch%2Fcfeck%2Fskulpture.git&a=blob&h=43b6b8a73c34c54befe3a8289908e6a8d6344077&hb=431fdd98819adc8ac1890c01312b81f08f68562f&f=src%2Fconfig%2Fconfigmanager.h
[3]
http://quickgit.kde.org/?p=scratch%2Fcfeck%2Fskulpture.git&a=blob&h=c9816cacd6bec235e776e314c9ea5400d2fb44be&hb=431fdd98819adc8ac1890c01312b81f08f68562f&f=kwin-client%2Fconfig%2Fconfigmanager.h
--
Christoph Feck
http://kdepepo.wordpress.com/
KDE Quality Team
More information about the Interest
mailing list