[Development] QML Settings

Dominik Holland dominik.holland at pelagicore.com
Tue May 12 13:17:35 CEST 2015

Hi Federico,

On 05/12/2015 12:14 PM, Federico Buti wrote:
> Hi list(s)
> I was considering the usage of Settings QML
> <http://doc.qt.io/qt-5/qml-qt-labs-settings-settings.html> for an app
> I'm working on. I just need to store two-three strings across mobile
> platforms and the API seems to fit my use case.
> However, I'm not able to make it work properly and I'm wondering if
> I'm using it the right way. I've tried the code proposed in
> documentation and I got the following error (for the x property):
> Can't load. Errors: (qrc:///main.qml:26:9: Cannot override FINAL property)

I think you got this error because you tried to define your own property
x ? In this case the property x is already defined as a final property
and because of that you cannot override it.

> Given this error, I've tried something else, similar to the other
> example proposed in the documentation:
> import QtQuick 2.4
> import Qt.labs.settings 1.0
> Window {
>     id: root
>     property string id1
>     Settings {
>         id: settings
>         property alias id1: root.id1

I didn't looked into the QML Settings yet, but I think it should be vice
versa. The property alias should be in root and the real propery in
settings. This way the root.id1 would be set once settings.id1 is set
(once the setting is loaded).

>     }
>     Component.onDestruction: {
>         root.id1 = "pippo"
>     }
>     Component.onCompleted: {
>         console.info(root.id1)
>     }
> }
> The idea was to set the value at the destruction of the component (i.e. app closing) so that, the next time application is started, the stored value is used. Unfortunately, each time the app is restarted no value is fetched from the settings, i.e. a sad "qml: " is printed to the console. What am I missing? Where is the error?
> Thanks in advance,
> F.
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development

Best Regards


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20150512/d9bbb2e3/attachment.html>

More information about the Development mailing list