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
New Developer
rainmaker2k
Posts: 11
Registered: ‎12-27-2012
My Device: Blackberry Dev Alpha
My Carrier: Vodafone

Re: Q_Invokable not working with a qmlRegisterType added class

Yeah all the qmlRegisterType calls are called before loading main.qml. That's all good.

 

The device logs contains a lot of messages. All of them are in the INFO or NOTICE category. Whenever I press the refresh button, the folling warning pops up in the device logs: 

TypeError: Result of expression 'movieListModel.reload' [undefined] is not a function.

 

So, this one I can understand, as the Q_INVOKABLE is ignored in some way. 

Please use plain text.
Developer
igosoft
Posts: 71
Registered: ‎09-19-2012
My Device: Z10 very soon
My Carrier: Play

Re: Q_Invokable not working with a qmlRegisterType added class

it's looking for reload method in DataModel (base class) instead your object. Please see my previouse post to solve your issue. If you need complete solution email me.

Please use plain text.
New Developer
rainmaker2k
Posts: 11
Registered: ‎12-27-2012
My Device: Blackberry Dev Alpha
My Carrier: Vodafone

Re: Q_Invokable not working with a qmlRegisterType added class

Thanks for your patience. I think you're right about it trying to find a DataModel reload method instead of my own. I created a simple Q_Object and added it as an attachedObject and tried the same setup and the c++ method did get hit in this situation.

 

I think I'll just have to wrap the DataModel in a new Q_Object class and have the datamodel as a property of the new class. 

 

Thanks for your help. 

Please use plain text.
New Developer
rainmaker2k
Posts: 11
Registered: ‎12-27-2012
My Device: Blackberry Dev Alpha
My Carrier: Vodafone

Re: Q_Invokable not working with a qmlRegisterType added class

I managed to solve the problem without changing much to the original classes.

 

It seems I made a mistake in the header file of MovieListModel. The invokable method was put in the section with private methods, which cascades won't let you invoke from a QML Javascript function. Moving it to the section with public methods solved it.

Please use plain text.
Developer
Zmey
Posts: 1,510
Registered: ‎12-18-2012
My Device: PlayBook, Z10, DAC

Re: Q_Invokable not working with a qmlRegisterType added class

Haha. Thanks for sharing the solution. :smileyhappy:
I had this thread bookmarked as "qml puzzle" as I couldn't understand why base class was referenced in the above context. :smileyhappy:

Andrey Fidrya, @zmeyc on twitter
Please use plain text.