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
Contributor
Dev_Brooke
Posts: 17
Registered: ‎06-19-2013
My Device: BlackBerry Z10
Accepted Solution

How to create a certain amount of elements in qml

I want to have a container containing images in qml but the number of images is variable.

 

What would I need to do to acheive this? Is it possible to do or do I need to know the exact amount of all elements before compiling the app?

 

Thanks for any advice - still learning.

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: How to create a certain amount of elements in qml

you can use createObject to create a qml object from an object definition.
How often you use it is totally up to you, for example in a for loop.
You can add these objects to a container, for example.
----------------------------------------------------------
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
YamilBracho
Posts: 713
Registered: ‎05-31-2010
My Device: 8520

Re: How to create a certain amount of elements in qml

There are some ways:

 1- Use a ListView.

 2. Populate the container via c++, creating the ImageView(s)s as needed.

 

HTH

 

 

Contributor
Dev_Brooke
Posts: 17
Registered: ‎06-19-2013
My Device: BlackBerry Z10

Re: How to create a certain amount of elements in qml

Thanks for both replies, I actually spent the last 2 days trying to accomplish what im trying with a listview but because the container I am adding the listview to is also contained within a list (listitemcomponent) I get problems (missing/out of place rows) so now I am going for the less pretty way which is a scrollview of images. It's not nearly as neat as a litview though.

 

I will look at createObject and using C++ to create variable amount  of elements but if anybody has the time to have a look at my first post on here which was earlier today then maybe I could revert back to ListViews within a ListView with a little expert knowledge.

 

 

http://supportforums.blackberry.com/t5/Cascades-Development/Multiple-Data-Models/td-p/2437029

 

Thank you.

Contributor
Dev_Brooke
Posts: 17
Registered: ‎06-19-2013
My Device: BlackBerry Z10

Re: How to create a certain amount of elements in qml

I am trying to use createObject and nearly have it working but I need to be able to pass a string to the new qml page for it to work.

 

how do I initialise an object using createObject with a string?

Developer
YamilBracho
Posts: 713
Registered: ‎05-31-2010
My Device: 8520

Re: How to create a certain amount of elements in qml

Developer
ekke
Posts: 1,571
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: How to create a certain amount of elements in qml

don't know if I understood it right

 

if you create objects and want to send  string to them,

then you can have a property inside your component,

initialize with myNewComponent.theString = "abc"

and inside the component have your code reacting on signal that theString changed

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

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

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner
Contributor
Dev_Brooke
Posts: 17
Registered: ‎06-19-2013
My Device: BlackBerry Z10

Re: How to create a certain amount of elements in qml

Thanks for your reply Ekke,

 

I was doing that but I thought it wasn't working up until recently, I'm starting to understand more now about qml, thanks for your help .

 

I know the answer to this question now and have implemented createObject it for myself.

Developer
ekke
Posts: 1,571
Registered: ‎04-08-2010
My Device: Z10 (red Limited Edition), Q10, Z30
My Carrier: Telekom.de, O2, Vodafone

Re: How to create a certain amount of elements in qml

great to hear

 

creating objects dynamically is very powerful and fast

(you can download Conference2Go EclipseCon from BB World - it's a free conference app for Eclipse dev conferences, go to sessions or tracks and action 'Overview': the complete Page is created dynamically into a zoomable ScrollView.

each Sessions is a Container created dynmically. each Container has properties like sessionId to be 'unique'. the height depends on duration, the X-Position on Room, the Y-position on starting time.

perhaps gives you an idea)

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

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

blog: http://ekkes-corner.org videos: http://www.youtube.com/user/ekkescorner http://vimeo.com/ekkescorner/videos
bb10-development: http://appbus.org Twitter: @ekkescorner