[SailfishDevel] How to use setContext() or what is recommended?!

Filip Kłębczyk fklebczyk at gmail.com
Wed Nov 13 15:21:19 UTC 2013


W dniu 13.11.2013 16:16, Jonni Rainisto pisze:
> Hi,
>
> Yes your setContextProperty() to rootContext is the right approach. Usually I do something like this:
>
>      QScopedPointer<QGuiApplication> app(Sailfish::createApplication(argc, argv));
>      QScopedPointer<QQuickView> view(Sailfish::createView());
>      MyClass data;
>      view->rootContext()->setContextProperty("myObject", &data);
>      Sailfish::setView(view.data(), "qrc:/main.qml");

I also recommend looking here (code example were very helpful to me):
http://qt-project.org/doc/qt-5.1/qtqml/qtqml-cppintegration-interactqmlfromcpp.html

Regards,
Filip


More information about the Devel mailing list