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
Highlighted
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone
Accepted Solution

how to load data into datamodel of listview which not the direct child of navigation pane

Hi,

 

I have two pages main.qml and score.qml and I want to display data by groupdata model using listview in score.qml.  The problem is as score.qml is not direct child of navigationpane,it is not able to locate the object of groupdatamodel and can't bind it. How can I display data into that in such case?

Rujuta Trivedi
Developer
Posts: 293
Registered: ‎10-15-2012
My Device: bb10 developer
My Carrier: Orange

Re: how to load data into datamodel of listview which not the direct child of navigation pane

you could use the objectName attribute on the listview, and then use findChild from C++ to locate it
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: how to load data into datamodel of listview which not the direct child of navigation pane

Tried but its not able to find using objectname too

Rujuta Trivedi
Developer
Posts: 293
Registered: ‎10-15-2012
My Device: bb10 developer
My Carrier: Orange

Re: how to load data into datamodel of listview which not the direct child of navigation pane

score.qml doesn't have to be a direct child - but it must be part of the navigation hierarchy otherwise findChild will not work.

 

Try setting the parent of score.qml to the navigationpane (when using createObject)

 

Otherwise you have two options:

 

1. You have created score.qml, so you must have its document root somewhere - use *that* to do a findChild()

2. Pass the QObject*  of the model into C++ and access it that way

Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: how to load data into datamodel of listview which not the direct child of navigation pane

Can you please explain the 2nd point. How to achieve it? I have also tried using attachedobject to the main.qml but it doesnt work

Rujuta Trivedi
Developer
Posts: 67
Registered: ‎09-01-2012
My Device: Dev Alpha
My Carrier: Bell

Re: how to load data into datamodel of listview which not the direct child of navigation pane

I'm surprised the attachedobject method didn't work. Can you try attaching score.qml just as a page and not a component definition?
Developer
Posts: 528
Registered: ‎10-06-2009
My Device: 9800,BB Dev Alpha,z10 limited edition
My Carrier: Vodafone

Re: how to load data into datamodel of listview which not the direct child of navigation pane

Thanks a lot,it works without component definition

Rujuta Trivedi