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
Bluenoser
Posts: 261
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

create ImageView object in Cascades

Hi,

 

  Can you create an ImageView object in Cascades on the fly?

Please use plain text.
Developer
DrShavargo
Posts: 133
Registered: ‎05-10-2013
My Device: Blackberry Z10
My Carrier: -

Re: create ImageView object in Cascades

[ Edited ]

What do you mean by "on the fly"? You can create it normally in QML:

 

ImageView {
    imageSource: "an_image.png"
}
 

 or in C++:

 

ImageView* imageView1 = new ImageView();
imageView->setImage(Image("an_image.png"));

 

Edit: check out the ImageView API.

----------------------------------------
Remember to mark the thread as solved at the post that solved your problem, and if you like a post, like it!
Please use plain text.
Developer
Bluenoser
Posts: 261
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: create ImageView object in Cascades

[ Edited ]

On the fly means that I can create them dynamically.I have created pages as ComponentDefinitions and then used createObject. I just haven't seen this used with ImageView and want to know if it is possible?

Please use plain text.
Developer
kamalakshan
Posts: 107
Registered: ‎06-12-2012
My Device: Dev Alpha C, Playbook
My Carrier: Loop

Re: create ImageView object in Cascades

You can use ImageView inside your pages defined in Component Definition. Like

http://blackberry.github.io/Cascades-Samples/data-rssnews-assets-main-qml.html

Basically ImageView itself is a control provided by the framework.
----------------------------------------------------------
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.
Developer
Bluenoser
Posts: 261
Registered: ‎04-04-2012
My Device: BlackBerry Z30/Z10/Z10LE/Q10/PlayBook

Re: create ImageView object in Cascades

[ Edited ]

The page is already created and want to add additional ImageViews depending on the users actions. They could be 1 to x ImageViews. The RSS example creates a page with an imageview in it. I just want the imageview and having been able to find any example or documentation on how to accomplish this.

Please use plain text.
Developer
DrShavargo
Posts: 133
Registered: ‎05-10-2013
My Device: Blackberry Z10
My Carrier: -

Re: create ImageView object in Cascades

Ah I see, my bad. Is this what you're looking for? For adding a component definition inside a Container (modified from this page):

 

Container {
    Button {
        text: "Click to create image"
        onClicked: {
             // Creates ImageView control and appends it
             // to the container
             var createdControl = imageComponent.createObject();
             container.add(createdControl);
        }
    }
    Container {
        id: container
    }
    attachedObjects: [
         ComponentDefinition {
             id: imageComponent
Container{ ImageView { imageSource: "assets///anImage.png" translationY: 50.0 }
} } ] }

 This should function for adding multiple identical ImageViews.

----------------------------------------
Remember to mark the thread as solved at the post that solved your problem, and if you like a post, like it!
Please use plain text.
New Developer
trieuchung
Posts: 41
Registered: ‎07-29-2012
My Device: 9650
My Carrier: sprint

Re: create ImageView object in Cascades

I have an Ideal that is create an imageview object in c++ then in qml have an button when user click that create new imageview object ! but I don't know pass a object in c++ to container create in qml...! 

--
Triệu Chung
VietNam National University
Please use plain text.