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 Contributor
Posts: 9
Registered: ‎04-16-2013
My Device: BB 10 Developer
My Carrier: --
Accepted Solution

NavigationPane properties and objectName explanation

Hello everyone!

 

I've been working with a variety of the sample apps that use NavigationPane objects (in QML) and have noticed that sometimes, the pages and/or lists that are within the NavigationPane look like properties of the pane:

 

NavigationPane {

    id: navigationPane

    firstPage: Page {

        id: pgMain

        content: Container {

            ListView {

                id: listView

                // set object name to let listView to be discoverable from C++

                objectName: "listView"

                layout: GridListLayout{}

                ...

 

Then, other times, the words I bolded simply aren't there.  Does this make a difference or have any significance? Also, when and why do you use "objectName?"  I have looked through the documentation on both of these topics and not found much explanation.

Developer
Posts: 656
Registered: ‎02-03-2010
My Device: Z10 LE
My Carrier: Rogers

Re: NavigationPane properties and objectName explanation

I don't put the firstpage or content and all works fine.

 

As for objectname.... You need that when trying get a pointer to that object from cpp



 


Steven Kader at JaredCo
   Follow me on Twitter    |     Mipixi.com :  Web App for Photo Sharing
New Contributor
Posts: 9
Registered: ‎04-16-2013
My Device: BB 10 Developer
My Carrier: --

Re: NavigationPane properties and objectName explanation

Thanks for the insight with objectName!
Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: NavigationPane properties and objectName explanation

objectName can also be used in QML, for example, when iterating children of a container to distinguish them.

 

firstPage and content are default properties. If property name is omitted, the children of the element will be binded to a default property (if there's one defined). More info on this:

http://qt-project.org/doc/qt-4.8/propertybinding.html#default-properties

Or even better example from Qt 5 docs (it still applies to 4.8):

http://qt-project.org/doc/qt-5.0/qtqml/qtqml-syntax-objectattributes.html#default-properties

 

 


Andrey Fidrya, @zmeyc on twitter