[Qt-qml] Settings / State Saving proposal for QML
Adriano Rezende
adriano.rezende at openbossa.org
Mon Nov 21 15:32:04 CET 2011
2011/11/17 João Abecasis <joao.abecasis at nokia.com>:
> The API is pretty minimal, here's example usage:
>
> Rectangle {
> id: main
> height: 480
> width: 640
> color: settings.color
>
> Settings {
> id: settings
> property string color: "blue"
> property alias height: main.height
> property alias width: main.width
> }
> }
>
> I pushed the code to a clone of the Desktop Components repository over on gitorious. There's some further information in the commit message:
>
> https://qt.gitorious.org/~biochimia/qt-components/biochimias-desktop/commit/c1ac32929065f24783f4d254d1786dce8202b274
>
> While this needs further refinement and exploration (e.g., ignore the fact that it is using QSettings underneath ;-), what do people around here think of this approach?
I like the API and the alias approach. It's very handy to keep simple
data persistence.
I think the implementation needs just some adjustments though; if the
object dies before the 500 ms, which is the storage delay, the data is
not stored on disk. Basically, calling store() in the destructor would
be enough, but that would not work with aliases depending on the
object hierarchy. So you need to cache the data or just remove the
delay, which is also ok I think, since QSettings already merge updates
behind the scenes.
Br,
Adriano
More information about the Qt-qml
mailing list