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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Highlighted
Developer
Posts: 27
Registered: ‎01-03-2013
My Device: Curve 8520
My Carrier: Warid
Accepted Solution

accessing QML attached objects in C++ and best practice for handling UI in classes

Hi,

I have actually 2 queries

 

1) How we can access attachedobjects defined in QML in C++ ?

 

2) I am loving development on Blackberry 10 as C++ is one of my favorites. But I am a little lost when it comes to handling UI in classes. For example when we create project through momentics we have a class called ApplicationUI. It handles all the stuff of UI (by default) we do in C++ . like for example creating UI from qml document and setting as root etc. I am now working on an app that have NavigationPane as root and then I keep pushing pages (as screens) . But right now code for all pages is inside my ApplicationUI. What is the best practice for keeping UI logic of each page in a separte C++ class ?

I also develop for Android which has separate class for each Activity so code do not get mixed for each Activity. Please guide me how can I keep UI logic of each Page in separate C++ class ?

Developer
Posts: 27
Registered: ‎01-03-2013
My Device: Curve 8520
My Carrier: Warid

Re: accessing QML attached objects in C++ and best practice for handling UI in classes

For 1st question I have found that we have "attachedObjects" property to retrieve all attached objects.

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: accessing QML attached objects in C++ and best practice for handling UI in classes

regarding your second question:
i think it is the easiest approach to keep all UI things in QML. You can easily put things into separate files there.

if you want to use c++ for the UI: can be done, too. just put it in separate classes and include those in your application class.
----------------------------------------------------------
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
Developer
Posts: 27
Registered: ‎01-03-2013
My Device: Curve 8520
My Carrier: Warid

Re: accessing QML attached objects in C++ and best practice for handling UI in classes

thanks.... for example if i have a qml file "test_screen.qml" .....is it a good practice that to handle its UI interaction in C++ I create a class "TestScreen" in test_screen.hpp/cpp file ?

 

secondly is it necessary to pass ApplicationUI object around to my other classes...or everything that I do in ApplicationUI can be done in other classes as well ?

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: accessing QML attached objects in C++ and best practice for handling UI in classes

These things depend on the complexity of your app.

I have different c++ classes that act as services or utils and they are all registered in qml, for example persistence, textutil, webservice etc

I handle all UI interactions in 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
Developer
Posts: 27
Registered: ‎01-03-2013
My Device: Curve 8520
My Carrier: Warid

Re: accessing QML attached objects in C++ and best practice for handling UI in classes

Alright...thanks a lot... Smiley Happy