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
Highlighted
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany
Accepted Solution

Align dynamically created components

I am using the RemoteImageView custom component shown here to download pictures.

How do i use the component properly in QML?

I use this code in a loop to create a couple of RemoteImageViews:

var imageView = remoteImageView.createObject(mainContainer);
imageView.url = "urltopicture"
mainContainer.add(imageView);

 The component works fine, but all images are layered upon eachother.

I would like to have a layout that adds them next to eachother, in the end using them as buttons.

----------------------------------------------------------
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.
@SimonHain on twitter
Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: Align dynamically created components

Make your mainContainer have a StackLayout with orientation LeftToRight.

That what you're asking? I assume it is currently a DockLayout
Like all of my posts
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Align dynamically created components

It kind of works, it seems the docklayout is kind of useless without its properties.
----------------------------------------------------------
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.
@SimonHain on twitter
Developer
Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: Align dynamically created components

DockLayout is generally really useful when you're layering components but I tend to use StackLayout. Only really use docklayout when needing things that either act like dialogs, components that float at the bottom of a listview or justifiying things left & right.
Like all of my posts
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Align dynamically created components

quick follow up question:
i guess a stacklayout fits everything within one stack (vertically or horizontically) without creating a second row/line when the first is full?
----------------------------------------------------------
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.
@SimonHain on twitter
Developer
Posts: 160
Registered: ‎01-27-2012
My Device: Playbook
My Carrier: Rogers

Re: Align dynamically created components

Try a FlowListLayoutProperties

---
If you find my post helpful please "like" it and "accept as a solution"
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Align dynamically created components


Dredvard wrote:

Try a FlowListLayoutProperties


But isn't that only used for ListViews?

 

----------------------------------------------------------
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.
@SimonHain on twitter
Developer
Posts: 160
Registered: ‎01-27-2012
My Device: Playbook
My Carrier: Rogers

Re: Align dynamically created components

My mistake.  I had assumed you were doing a listview.

 

Actually I'm intending on doing the same thing - just the container size being dependant on the screen orientation. 

Thats's the only api I'm aware that does that function.  I wonder as a workaround if you could just add your images to the listview in the container and have it automatically move the items to fit the area.

---
If you find my post helpful please "like" it and "accept as a solution"
Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: Align dynamically created components

I am currently using a StackLayout and set the min/max size of my components to have them align nicely.
In QML i create a new container for every 4 items and add them to a topbottom stacklayout.
----------------------------------------------------------
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.
@SimonHain on twitter