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
nareshkodumuri
Posts: 125
Registered: ‎04-28-2012
My Device: BlackBerry 9800
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 Device: BB10 alpha-BB10 developer
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: 1,428
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, 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: http://www.youtube.com/user/ekkescorner
bb10-development: http://appbus.org Twitter: @ekkescorner
Please use plain text.
Developer
nareshkodumuri
Posts: 125
Registered: ‎04-28-2012
My Device: BlackBerry 9800
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.
Developer
ankur_siwach
Posts: 142
Registered: ‎09-28-2012
My Device: Blackberry Developer
My Carrier: Aircel

Re: attachedObjects property in qml....?

i am new to native development ,

m still not getting what the use of attachedObjects in qml..

can some one can explain me in brief and simple way..


----------------------------------------------------------
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.
Please use plain text.