I have a problem and I can't find a solution to it, I hope you to find it here: I did a ListView with its model and its delegate and so on, like this:
Item {
id: creation; width: parent.width ; height: parent.height
.....
ListView {
id: mainViewLiist
model: CreationModel {id: modelCreation}
delegate: delegateCreation
width: parent.width; height: parent.height; x: -(screen.width * 1.5);
cacheBuffer: 100;
}
}
the delegate includes Text, TextEdit, etc.... something like this:
Component {
id: creationDelegate
Item {
id: itemCreate
....
Row {
id: rowSerie
spacing: 5
Text {
id: seriesLabel
text: "Series:"
....
}
TextEdit {
id: seriesTextEdit
text: ""
....
}
}
....
}
....
}
Inside the same Item, "creation", there is also a ToolBar with two Buttons, something like this:
ToolBar { id: toolBarCreation; height: 40;
width: parent.width;
opacity: 1.0
button1Label: "Back"
button2Label: "Create"
onButton1Clicked:
{
...
}
onButton2Clicked:
{
...
}
}
What I want is this: when I click on the second button, "Create", I want simply to show with console.log(arg1,...) what is written in the TextEdit called "seriesTextEdit" of every item in the listView. For example, if my listview contains 10 items and the user insert a valued in all the TexTedit of all the item, how can I access to those data? Thank you very much, Giammarco
The ListView could be the wrong class to use since it destroys items which are not in the visible area and creates new ones which get visible. If you don't want that use a Repeater.
Anyway you can access the ListView's child items with ListView.contentItem.children. I tried and it contained an additional element (maybe the header).
I would suggest to have an alias property for the TextEdit text (seriesName in my example) in the root of your list item delegate. Probably you need the same for the index because as said, the ListView might not contain elements for all your model items. Then you can use a loop to get the texts.
print(mainViewLiist.contentItem.children.length);
for (var i = 0, l = mainViewLiist.contentItem.children.length; i < l; i++) {
var child = mainViewLiist.contentItem.children[i];
print(i, ": ", child, "=", child.text);
}