[Development] Settings API for QML

André Somers andre at familiesomers.nl
Tue Dec 11 17:13:03 CET 2012

Op 11-12-2012 16:37, Bache-Wiig Jens schreef:
>> To get the discussion going, here's my suggestion for that API:
>> PersistentSettings
>> {
>>     property bool loadOnStartup: true
>>     property bool saveOnExit: true
>>     function load()
>>     function save()
>> }
> I would also consider an even simpler API. How about we introduce a new keyword for persistent properties and make it part of the language.
> Rectangle {
>      id: root
>      persistent property width: 400
>      persistent property height: 300
> }
> What this means is that the application will automatically store its persistent properties on exit and recall those properties on startup. By default they would be initialised to the bound value.
> It will need some attached properties or other meta data to override default storage locations etc. And we also need to enforce id's to keep values unique per qml file.
> Jens
Interesting idea, but isn't that a recipe for horror if you ever want to 
change the structure of your application? To make it possible to keep 
your application settings if you change your application structure, you 
will need to set those attached properties. A default generated value 
will not suffice. That either leads to forcing users to set it if they 
use the persistent keyword, or leading them into big trouble with 
application maintenance in the future. Neither sounds attractive.

I think you simply can't assume that the tree of id's or even the files 
they appear in is going to be stable across application versions.


More information about the Development mailing list