Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Regular Contributor
Sumitava_Datta
Posts: 83
Registered: ‎02-18-2013
My Device: Blackberry 10
My Carrier: airtel

How to get string value from c++ file to qml file in blackberry 10 cascades?

I am call a function from App.cpp.In that function a QString variable value is set.I want this value in main.qml because depends on this string value I want to perform several task in main.qml. Please help me .......:smileyhappy: Thanks in advance.

Please use plain text.
Developer
YamilBracho
Posts: 713
Registered: ‎05-31-2010
My Device: 8520
My Carrier: Movistar

Re: How to get string value from c++ file to qml file in blackberry 10 cascades?

You can "export" the value from C++ to QML using QDeclarativePropertyMap or using a PROPERTY

Please check http://developer.blackberry.com/cascades/documentation/dev/integrating_cpp_qml/index.html

Please use plain text.
Regular Contributor
Sumitava_Datta
Posts: 83
Registered: ‎02-18-2013
My Device: Blackberry 10
My Carrier: airtel

Re: How to get string value from c++ file to qml file in blackberry 10 cascades?

Thanks for your feedback.

Please use plain text.
Developer
ankursahu19
Posts: 60
Registered: ‎03-20-2013
My Device: Z10(Red Limited Edition)
My Carrier: MY COMPANY

Re: How to get string value from c++ file to qml file in blackberry 10 cascades?

Make that function Q_INVOKABLE like

in App.hpp

define a function like:

Q_INVOKABLE QString getValue();

 

and then in the constructor of

QmlDocument *qml = QmlDocument::create("asset:///main.qml");
qml->setContextProperty("app",app);
 
and you can use this function in main.qml like
app.getValue()

 

Please use plain text.
Regular Contributor
Sumitava_Datta
Posts: 83
Registered: ‎02-18-2013
My Device: Blackberry 10
My Carrier: airtel

Re: How to get string value from c++ file to qml file in blackberry 10 cascades?

I get the string value in qml from cpp.I just call a function of cpp file which is emit the signal to the qml.I am just use the qmlRegisterType.

 

Thanks every one.......:smileyhappy: for your feedback.........

 

Please use plain text.