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
Posts: 188
Registered: ‎09-03-2012
My Device: Blackberry 10
Accepted Solution

How to pass reference of the GroupDataModel object from QML to C++?

I would like to hold reference of the GroupDataModel by passing it from QML to C++.

 

The C++ side is as follow:

 

void App::setCurrentGroupModel(GroupDataModel &groupModel) {
    currentGroupModel = &groupModel;
}

 

The QML side is as follow:

 

app.setCurrentGroupModel(favoriteGroupModel);

 

I received the following error:

 

assets//main.qml:246: Error: Unknown method parameter type: GroupDataModel&

 

I'm still learning QML and C++. Just wondering what did I do wrong to receive the above error?

 

Thanks!

Highlighted
Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: How to pass reference of the GroupDataModel object from QML to C++?

You should probably just get a reference to your listview with container->findChild<ListView*>("objectName") and then you always have access to the datamodel that its using

Like all of my posts
Developer
Posts: 188
Registered: ‎09-03-2012
My Device: Blackberry 10

Re: How to pass reference of the GroupDataModel object from QML to C++?

Yeap that works. Pass the id there.

 

Thanks!