[SailfishDevel] Saving state/config
Thomas Tanghus
thomas at tanghus.net
Fri Nov 15 17:32:09 UTC 2013
On Friday 15 November 2013 20:50 Andrey Kozhevnikov wrote:
> both are easy. check Qt Assistant. examples and api reference are inside
> your Qt Creator ;)
Forgive me for non-SailfishOS questions, but I must be doing something wrong,
even if it's easy ;)
My main is now:
int main(int argc, char *argv[]) {
QGuiApplication *app = SailfishApp::application(argc, argv);
QQuickView *view = SailfishApp::createView();
QSettings *settings = new QSettings("Tanghus",
"net.tanghus.currencyconverter.sailfish");
view->rootContext()->setContextProperty("settings", settings);
view-
>setSource(SailfishApp::pathTo("qml/net.tanghus.currencyconverter.sailfish.qml"));
view->showFullScreen();
return app->exec();
}
And in ApplicationWindow I can see it's instantiated:
Component.onCompleted: {
console.log('Ready', settings);
}
Prints: Ready QSettings(0x70b633a0)
But if I use it like:
refreshInterval = settings.value('refreshInterval', 3600).toInt();
I get:
file:///opt/sdk/net.tanghus.currencyconverter.sailfish/usr/share/net.tanghus.currencyconverter.sailfish/qml/net.tanghus.currencyconverter.sailfish.qml:64:
TypeError: Object [object Object] has no method 'value'
I'm sure this is very trivial - but atm I'm stuck :P
> On 15.11.2013 20:48, Thomas Tanghus wrote:
> > On Friday 15 November 2013 20:26 Andrey Kozhevnikov wrote:
> >> use QSettings as Jonni said and register own component to use in qml, if
> >> need, or export single class instance via setContextProperty
> >
> > The latter sounds like the easiest approach.
> >
--
Med venlig hilsen / Best Regards
Thomas Tanghus
More information about the Devel
mailing list