[Development] QML Settings

Federico Buti bacarozzo at gmail.com
Tue May 12 12:14:37 CEST 2015


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)

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

    }


    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20150512/fac5b4ca/attachment.html>


More information about the Development mailing list