[Development] Settings API for QML
pierluigi.fiorini at gmail.com
Fri Aug 2 00:34:42 CEST 2013
2013/8/1 Thiago Macieira <thiago.macieira at intel.com>:
> On quinta-feira, 1 de agosto de 2013 07:58:41, André Somers wrote:
>> I do see a use for using a schema right there. Settings can be accessed
>> from all over the application. If you use QSettings or QConfiguration or
>> whatever for that directly, it means that everywhere you need a specific
>> value, you also need the default value. So, you end up duplicating the
>> default value to several places in the code, and it won't be easy to
>> find all occurrences either. If you define the defaults centrally, at
>> least you don't have that issue.
> In the past, KDE has solved this problem by processing the schema file (it's
> never been called that in KDE, but turns out it's what the .kcfg files are) and
> generating a nice C++ class to access, with the defaults built-in and the
> proper C++ type safety.
> This solves the runtime overhead problem by transferring it to a compile-time
But it's not usable by pure QML applications as it requires code to be
That's why I was thinking about creating a meta object at runtime from
the schema file.
On the other hand a pure QML application is fine with Qt.labs.settings
and C++ code generated processing the schema file might be registered
as a type and used from QML for a QML/C++ application use case.
> Since I'm not convinced, the objection still stands for now: schemas must not
> be a mandatory runtime requirement. They can be present only if optional and
I'm fine with having schemas optional, what about:
make something like Qt.labs.settings usable from C++ applications
without creating a QML component, a "dumb" builtin backend for the INI
format, optional plugins for dconf and other smarter backends and a
KDE like processing tool to generate the C++ code for you.
What is very important to me and should always be available with the
settings API, are changes notifications, but that could be achieved
even by the builtin INI format backend rereading the configuration
file when it changes.
Out of the box experience
More information about the Development