To make the settings persistent, you have to set http://doc.qt.io/qt-5/qml-qt-labs-settings-settings.html#application-identifiers (note however that settings Qt.application.name & Co won't probably help in this case (bug?)).
Konstantin 2015-05-13 22:18 GMT+04:00 Federico Buti <bacaro...@gmail.com>: > Hi, > > I've inverted the approach, i.e. I've defined the alias in the root > component and the two property in the Setting type. Result: it still does > not work. > > Is there anything specific that should be done? > > Thanks to everyone. > F. > 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.holl...@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@qt-project.orghttp://lists.qt-project.org/mailman/listinfo/development >> >> >> Best Regards >> Dominik >> >> -- >> >> >> _______________________________________________ >> Development mailing list >> Development@qt-project.org >> http://lists.qt-project.org/mailman/listinfo/development >> >> > > _______________________________________________ > Development mailing list > Development@qt-project.org > http://lists.qt-project.org/mailman/listinfo/development > >
_______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development