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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Contributor
Posts: 9
Registered: ‎07-12-2013
My Device: z10,q10
My Carrier: fdf

Issue in assignment from jsobject to Q_PROPERTY

Hi,

    As per my requirement,trying to assign jsobject from js file to Q_PROPETY of cpp side.But it's getting crashed in my application.Here Q_PROPERTY taking as QVariant type but it's not working as per expected.

 

Here i am giving some code snippet in below for more info.

   

//mycpp.cpp file

  Q_PROPERTY(QVariant onSelection READ onSelection WRITE setOnSelection NOTIFY onSelectionChanged)

//myjs.js file

function onSelection() {
    console.log("Listbox on selection changed");
}

function frmHome_btn_onClick_seq0(eventobject) {
   mycpp.onSelection = onSelection;//--this point crashed.

Note:--If i made it(onSelection method) as Q_INVOKABLE slot then it's working fine but as per requirement it should be Q_PROPERTY.
};

 

Any help would be much appreciated.

 

Thanks in advance

sk

Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Issue in assignment from jsobject to Q_PROPERTY

Do you have a setOnSelection function? You need that. Also, why is the property called "onSelection"? That sounds a lot like a signal.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
New Contributor
Posts: 9
Registered: ‎07-12-2013
My Device: z10,q10
My Carrier: fdf

Re: Issue in assignment from jsobject to Q_PROPERTY

Hi ,

Thanks for reply.yes i have setOnselection method.Though it seems like predefined signal but It's my own defined property.Apart from jsobject if i assign anything else(interger,string...) it's working fine.

 

Thanks

Sk

Highlighted
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: Issue in assignment from jsobject to Q_PROPERTY

What kind of object does your setOnSelection method accept? And how does it not work? Is the method getting called? What are you trying to pass in?

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
New Contributor
Posts: 9
Registered: ‎07-12-2013
My Device: z10,q10
My Carrier: fdf

Re: Issue in assignment from jsobject to Q_PROPERTY

[ Edited ]

Hi Paul,

Thanks for reply.

      In Qt property, trying to assign values either some string or object.All taking as QVariant type  in qt side.Please find the below given examples on js assignment to qt property.Please let me know if you need more details.

 

Case -1:-

//Js FIle

function MyMethod() {

}

 

MyObj.onSelection = MyMethod(JsObject)--->here crashing --setOnselection method of cpp side not calling--Control not going to cpp side.It's crashing here only.

[In cpp side this js object is nothing but --- QVariant(QVariantMap, QMap(("arguments", QVariant(, ) ) ( "callee" ,  QVariant(, ) ) ( "caller" ,  QVariant(, ) ) ( "length" ,  QVariant(int, 0) ) ( "name" ,  QVariant(QString, "MyMethod") ) )  ) ]

 

Case -2:--

MyObj.onSelection = "test"--->Working Fine

[In cpp side this js string is nothing but --- QVariant(QString, "test") ]

 


Note:--If i call setOnselection(MyMethod) function directly then it's working fine but in case of property no need to call directly the function(setOnselection) rather it sould call implicity when we assign some value to property(onselection).

 

Thanks & Regards,

Skbb