Yes, if you read the documentation pragma library cannot access qml properties directly. So its a feature.
http://qt-project.org/doc/qt-5.0/qtqml/qtqml-javascript-resources.html#shared-javascript-resources-libraries re, Jonni ________________________________ From: devel-boun...@lists.sailfishos.org [devel-boun...@lists.sailfishos.org] on behalf of antonio.cano.go...@ovi.com [antonio.cano.go...@ovi.com] Sent: Thursday, February 27, 2014 12:17 PM To: Sylvain B.; Sailfish OS Developers Subject: Re: [SailfishDevel] QML C++ Integration not working in Sailfish Hi sylvain, This is not the case a renamed the variable so the have exactly the same name. On the other hand, may be the problem is that I am calling it from .js file by the next code: .pragma library .import QtQuick 2.0 as QQ var appState; function getAppState() { return appState; } function newAppState(page) { appState = page; getAppState().k=1; getAppState().m=2; return appState; } // Funciones especificas function createBloomFilter() { console.log("Voy a llamar a generate filter") bloomfiltersdata.generateFilterInvokable2() console.log("Ya he llamado a generate filter") } And I call this from the qml by: import QtQuick 2.0 import Sailfish.Silica 1.0 import "pages" import "pages/content" import "pages/content/logic.js" as Logic import fi.helsinki.cs 1.0 ApplicationWindow { initialPage: Component { FirstPage { } } cover: Qt.resolvedUrl("cover/CoverPage.qml") id: appWin property var appState: Logic.newAppState(appWin); property ApplicationWindow appWin: appWin property Bloomfilters bloomfilters: bloomfilters property var k property var m property bool filterCharged: false } Someone seems something unusual in this code? Best Regards and Thanks, A. Cano El Miércoles 26 de febrero de 2014 13:24, Sylvain B. <sth...@hotmail.com> escribió: Yes, add a "s" You declared "bloomfiltersdata" and you are trying to use bloomfilterdata... ________________________________ Date: Wed, 26 Feb 2014 04:02:22 -0800 From: antonio.cano.go...@ovi.com To: devel@lists.sailfishos.org Subject: Re: [SailfishDevel] QML C++ Integration not working in Sailfish Hi Andrey, The output is: ReferenceError: bloomfilterdata is not defined I am calling it from a .js Some idea about how can I make that this is also defined there. Thanks! El Miércoles 26 de febrero de 2014 12:18, Andrey Kozhevnikov <coderusin...@gmail.com> escribió: start app in terminal and show output please On 26.02.2014 17:15, antonio.cano.go...@ovi.com<mailto:antonio.cano.go...@ovi.com> wrote: Hi Thomas, I did both modification but the code does not work yet. Here is the new code: QGuiApplication *app = SailfishApp::application(argc, argv); QQuickView *view = SailfishApp::createView(); Bloomfilters * bloomfilters = new Bloomfilters(); view->rootContext()->setContextProperty("bloomfiltersdata", bloomfilters); view->setSource(SailfishApp::pathTo("qml/bloomfilter.qml")); view->showFullScreen(); return app->exec(); El Miércoles 26 de febrero de 2014 12:01, Thomas Perl <th.p...@gmail.com><mailto:th.p...@gmail.com> escribió: On 2014-02-26 11:48, antonio.cano.go...@ovi.com<mailto:antonio.cano.go...@ovi.com> wrote: > I tried this: > > QGuiApplication *app = SailfishApp::application(argc, argv); > QQuickView *view = SailfishApp::createView(); > Bloomfilters * bloomfilters = new Bloomfilters(); > view->setSource(SailfishApp::pathTo("qml/bloomfilter.qml")); > view->showFullScreen(); > view->rootContext()->setContextProperty("Bloomfilters", bloomfilters); > return app->exec(); > > But it is not working yet. Two things: 1. Call setContextProperty() right before before setSource(), so it's already available when the QML content is loaded. 2. Use lowercase for context property names ("bloomfilters" instead of "Bloomfilters"). In some places, QML interprets IDs starting with an upper case letter as a type name, and that won't work then, therefore stick to lowercase. HTH :) Thomas _______________________________________________ SailfishOS.org Devel mailing list _______________________________________________ SailfishOS.org Devel mailing list _______________________________________________ SailfishOS.org Devel mailing list
_______________________________________________ SailfishOS.org Devel mailing list