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
Highlighted
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany
Accepted Solution

Use a custom class in a qml signal

I want to use a custom class in a qml signal, but have difficulties implementing that correctly.

 

My class is OutgoingInputs

I call

qRegisterMetaType<OutgoingInputs*>("OutgoingInputs");

 to register a pointer to it as a meta type, which seems to be needed, but when i also use

Q_DECLARE_METATYPE(OutgoingInputs*)

 in the header file of the class i get a compile error.

Do I have to register it without a pointer (got the idea from here ) or is there some other obvious error?

 

Is there an example how to do that?

I can receive the signal if my slot does not use any parameters.

 

----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
Developer
Posts: 174
Registered: ‎03-05-2009
My Device: Dev Alpha
My Carrier: -

Re: Use a custom class in a qml signal

i don't think you need to register as metatype....a simple register  should do it as it is the same as using the object in QML:

qmlRegisterType<OutgoingInputs>("mynamespace",1,0,"OutgoingInputs");

 

found this on the qt forums:

http://qt-project.org/forums/viewthread/9657

 

hope it helps!

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Use a custom class in a qml signal

Thanks lew, after some experimenting i resolved the issue, it seems qmlRegisterType is indeed sufficient.
I am successfully receiving QVariants with the complex object in it.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter