Adriano Rezende wrote: > 2011/11/17 João Abecasis <joao.abeca...@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.
It's a known issue. Width and height get changed to 0 (zero) before the destructor is called (I get notifications for those changes as well), making the example useless. Another issue that I just realized is open is validation of settings when reading from external sources. For now, only the type is checked. Cheers, João _______________________________________________ Qt-qml mailing list Qt-qml@qt.nokia.com http://lists.qt.nokia.com/mailman/listinfo/qt-qml