08-30-2012 06:46 AM
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.
08-31-2012 10:37 AM
Not sure if you had a chance to read the description about the attachedobjects
https://developer.blackberry.com/cascades/referenc
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.
08-31-2012 03:23 PM
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:
ekke
09-03-2012 01:52 AM
Hi,
Thanks for ur reply.Now i got an idea about attached objects and it's usage.Thanks for helping me.
Regards,
Naresh Kodumuri.