Dynamically allocating images
-
My project is starting to get a little out of hand in terms of the amount of times I have to create images and call functions. for example, I have 5 identical images in a row
@
Image {id: movie_list1; x: -342; y: 502; width: 100; height: 100; ....
Image {id: movie_list2; x: -342; y: 502; width: 100; height: 100; ....
Image {id: movie_list3; x: -342; y: 502; width: 100; height: 100; ....
Image {id: movie_list4; x: -342; y: 502; width: 100; height: 100; ....
Image {id: movie_list5; x: -342; y: 502; width: 100; height: 100; ...
@Can I just make it something like
@
for i to 5
Image {id: movie_list; x: -342; y: 502; width: 100; height: 100;
@ -
Try repeater, ListView or other view according to your need
//pseudo codes
@
ListModel{
id: photoModelListElement{name: "movie_list1"} //....and so on
}
ColumnLayout{
Repeater {
model: photoModel
Image {
width: 100; height: 40
x: -342; y: 502
source: name
}
}
}
@or a more simple one
@
property var names : {"movie1", "movie2"}ColumnLayout{
Repeater {
model: names
Image {
width: 100; height: 40
x: -342; y: 502
source: modelData
}
}
}
@