user2085965
user2085965

Reputation: 403

How to pass data to java script file in BB10 cascades.?

I need to show line,bar and candle charts in BB10 cascades. I have all 3 java script files, but I need to pass data to those script file through c++ code. How can I do that in BB10 cascades.?

Please Help.

Thanks in advance.

Upvotes: 1

Views: 185

Answers (1)

Bojan Kogoj
Bojan Kogoj

Reputation: 5649

Put this in your .cpp file in main

qml->setContextProperty("app", this);

then somewhere else in cpp

QString ApplicationUI::myFunction() {
    return "my data";
}

and you call it from QML like this (put this in onCreationCompleted):

var data = app.myFunction();

Make sure that function is Q_INVOKABLE in .hpp file!

A little documentation on this: C++ and QML integration

Upvotes: 2

Related Questions