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: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

findChildren doesn't find all Children in QML from Cpp

normaly I have no problem to find objects from QML in Cpp like

Application::instance()->scene()->findChild<
			GroupDataModel*>("partsDataModel");

 

but in a more complex scenario it seems not all children were found / known:

TabbedPane

    Tab

        Sheet

            TabbedPane

                  Tab

                      NavigationPane

                           Page with ListView and GroupDataModel

 

Page with ListView is instantiated (dynamically), but child not found

the other way works: I can ask Cpp for a List of QObject* and insert into DataModel from QML

tried to find the Sheet - also not found

 

following scenario works:

TabbedPane

    Tab

        NavigationPane

              Page with ListView and GroupDataModel

 

even works in a more complex NavigationPane where at first another ListView pas pushed, then from there a DetailsPage was pushed and then via Actionitem the ListView w GroupdataModel was pushed

 

is this expected behaviour that scene() doesn't find children from sub-workflows on top of Sheets from a Tab ?

 

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: findChildren doesn't find all Children in QML from Cpp

Please log a bug

 

DIT

 

This may not be a supported usecase. If findchild isn't working, it sounds like the sheet isn't being set up as a child of the tab.

 

I would recommend you come at it from the other direction, and provide your C++ objects to QML, and avoid findChild whenever possible. This makes it easier to change your UI later should you want to.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Developer
Posts: 17,012
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: findChildren doesn't find all Children in QML from Cpp


PBernhardt wrote:

I would recommend you come at it from the other direction, and provide your C++ objects to QML, and avoid findChild whenever possible. This makes it easier to change your UI later should you want to.


Unfortunately it makes tracking segfauls impossible.

I prefer sending signals to qml.

----------------------------------------------------------
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
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: findChildren doesn't find all Children in QML from Cpp

Which segfaults are you worried about?

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker
Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: findChildren doesn't find all Children in QML from Cpp


simon_hain wrote:

PBernhardt wrote:

I would recommend you come at it from the other direction, and provide your C++ objects to QML, and avoid findChild whenever possible. This makes it easier to change your UI later should you want to.


I prefer sending signals to qml.


if the event isn't coming from UI (QML) would be great always to have access to ALL qml objects via findChild

 

will create an issue later

(just back from MobileDeveloperConference and preparing a Cascades Workshop I'm giving next week)

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Retired
Posts: 749
Registered: ‎12-16-2008
My Device: BlackBerry Z30
My Carrier: Bell

Re: findChildren doesn't find all Children in QML from Cpp

Thanks Ekke. It's probably something funky with how sheets intereact with tabs. To be honest, I am still suprised that works at all.

Paul Bernhardt
Application Development Consultant
BlackBerry
@PBernhardt

Did this answer your question? Please accept this post as the solution.
Found a bug? Report it to the Developer Issue Tracker