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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Cascades Development

Reply
Developer
nareshkodumuri
Posts: 94
Registered: ‎04-28-2012
My Carrier: BlackBerry

attachedObjects property in qml....?

Hi,

 

I am not able to understand the concept and usage of attachedObjects Property in qml.please anybody explaine the concept and usage of attachedObjects property  with an example.

 

Thanks,

Naresh Kodumuri.

Please use plain text.
BlackBerry Development Advisor
lingBB10Dev
Posts: 35
Registered: ‎08-01-2012
My Carrier: T-Mobile

Re: attachedObjects property in qml....?

Not sure if you had a chance to read the description about the attachedobjects

 

https://developer.blackberry.com/cascades/reference/bb__cascades__uiobject.html#attachedobjects

 

Usually, the attachedObjects property is  used to contain "non-UI" objects,  e.g.: objects wrapping some "business logic". They are used to reduce the code of exchanging information between qml and c++ code.

 

There are some example apps you may want to consult for the usages of attachedObjects.

 

https://github.com/blackberry/Cascades-Samples

 

For example:

 MultithreadingCallBacks101,  it uses attachedObjects property to contain counter objects.

 

 FunWithSensors, it uses attachedObjects property to contain sensor object.

Please use plain text.
Developer
ekke
Posts: 908
Registered: ‎04-08-2010
My Carrier: vodafone

Re: attachedObjects property in qml....?

attached Objects are not only used for Business Logic.

 

You have to use attached Objects to attach UI COntrols or Pages etc not visible from startup.

 

one example: Sheets

 

attachedObjects: [
        Sheet {
            id: loginSheet
            content: LoginSheet {
                id: loginContent
            }
        },
        Sheet {
            id: helpSheet
            content: HelpSheet {
                id: helpContent
            }
        }
]

 then it's easy to say helpSheet.visible = true to push the sheet on top

 

or a NavigationPane can hold all the Pages as attached Objects

and you can push them easy:

 

ActionItem {
                title: qsTr ("About")
                ActionBar.placement: ActionBarPlacement.OnBar
                onTriggered: {
                    navigationPane.push(aboutSite)
                }
            }

 

I'm also using attachedObjects to store Images there if I per ex. switch many times between them (per ex. for Landscape / Portrait)

 

attachedObjects: [
            // we need this image as background for the HomeScreen
            // because we toggle often we use an ImageTracker
            // TODO: different background images for different sizes of smartphone or tablet
            ImageTracker {
                id: backgroundLandscape
                imageSource: "asset:///images/bg-1280x768.png"
            }, 
            // the BackgroundImage
            ImageTracker {
                id: backgroundPortrait
                imageSource: "asset:///images/bg-768x1280.png"
            },
            // the Website
            ImageTracker {
                id: websiteImage
                imageSource: "asset:///images/website.png"
            },
            // the Fan-of-The-Month
            ImageTracker {
                id: fomImage
                imageSource: "asset:///images/fom-61.png"
            },
            // application supports changing the Orientation
            OrientationHandler {
                onUiOrientationChanged: {
                    if (uiOrientation == UiOrientation.Landscape) {
                        backgroundImage.image = backgroundLandscape.image
                    } else {
                        backgroundImage.image = backgroundPortrait.image
                    }
                }
            }
        ]

 

 

only some examples

 

you'll find all of them now (or after my next pushes ;-) here in this Cascades Open Source Project by me:

 

opendataspace

 

ekke

 

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

BlackBerry Elite Developer
International Development Mobile Apps BlackBerry 10 Cascades
Cascades - Workshops / Trainings / Bootcamps

Open Source Enthusiast
blog: http://ekkes-corner.org videos: https://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
Developer
nareshkodumuri
Posts: 94
Registered: ‎04-28-2012
My Carrier: BlackBerry

Re: attachedObjects property in qml....?

Hi,

 

Thanks for ur reply.Now i got an idea about attached objects and it's usage.Thanks for helping me.

 

Regards,

Naresh Kodumuri.

Please use plain text.