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
Developer
simon_hain
Posts: 16,010
Registered: ‎07-29-2008
My Device: Z10 LE
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
Please use plain text.
Developer
Developer
lew
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!

Please use plain text.
Developer
simon_hain
Posts: 16,010
Registered: ‎07-29-2008
My Device: Z10 LE
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
Please use plain text.