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
Contributor
Posts: 28
Registered: ‎02-07-2013
My Device: blackberry 10
My Carrier: vodafone
Accepted Solution

qml calling function in main.cpp

hi,

 I want to call a function in main.cpp from main.qml!  Is there any way to do this?

Help me to solve this!

Contributor
Posts: 25
Registered: ‎02-14-2013
My Device: Non Blackberry User
My Carrier: Nothing

Re: qml calling function in main.cpp

[ Edited ]

Here you can write definition in .cpp file for function and can call it from qml file check it here.. code in QML file

 

Button {
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center

text: qsTr("Share!")
onClicked:
{
SociaShare.share()
}
}

 

But this is for another class you create with main.cpp..Mainly main.cpp is for localization and getting application instance..Please check at your end. Hope it will help you!

 

Regards

Dev

Contributor
Posts: 25
Registered: ‎02-14-2013
My Device: Non Blackberry User
My Carrier: Nothing

Re: qml calling function in main.cpp

This way you can call it from main too I guess..Not sure :smileysad:

Developer
Posts: 679
Registered: ‎08-09-2010
My Device: Not Specified

Re: qml calling function in main.cpp

Hi Paul24,

 

  Please check below link

 

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

 

 

-------------------------------------------------------------------------------

 

feel free to press the like button on the right side to thank the user that helped you.

Developer
Posts: 313
Registered: ‎05-31-2010
My Device: Alpha 10, Bold 9900, Storm 9530, Tour 9630, Curve 9320, Curve 8900
My Carrier: All

Re: qml calling function in main.cpp

Append to the above reply, if want to transfer the collection type of variable between QML and C++, it can use QVariant and QVariantMap




p(^_^)q
Good good study, day day up