[Development] QML Settings

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


Hi Dominik.

No, the documentation is pretty clear about that: alias inside the
Settings. That's why I've linked it.
As for the error, that's because the documentation example aliases
"x"...but Settings has its own "x", obviously! I just got it few minutes
after I have sent the mail. Trivial error.

Anyhow, your approach is logical and does make perfectly sense. I'm going
to test it and report back.

Thanks for your time!
F.


---
Federico Buti

On 12 May 2015 at 13:17, Dominik Holland <dominik.holland at pelagicore.com>
wrote:

>  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 listDevelopment at qt-project.orghttp://lists.qt-project.org/mailman/listinfo/development
>
>
> Best Regards
>  Dominik
>
> --
>
>
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20150512/96c23467/attachment.html>


More information about the Development mailing list