Get data from a TextEdit in a ListView
Hallo there,
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:
[CODE]
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;
}
}[/CODE]
the delegate includes Text, TextEdit, etc.... something like this:
[CODE]Component {
id: creationDelegate
Item {
id: itemCreate
....
Row {
id: rowSerie
spacing: 5
Text {
id: seriesLabel
text: "Series:"
....
}
TextEdit {
id: seriesTextEdit
text: ""
....
}
}
....
}
....
}[/CODE]
Inside the same Item, "creation", there is also a ToolBar with two Buttons, something like this:
[CODE]ToolBar { id: toolBarCreation; height: 40;
width: parent.width;
opacity: 1.0
button1Label: "Back"
button2Label: "Create"
onButton1Clicked:
{
...
}
onButton2Clicked:
{
...
}
}[/CODE]
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
Re: Get data from a TextEdit in a ListView
Hi,
If you have mapping of the TextEdit that you have in delegate back to the model, then you can access it -
for(var i = 0; i < myModel.count; ++i) {
console.log(myModel.get(i).text1);
}
Also please see this [URL="http://stackoverflow.com/questions/9775858/how-to-access-a-listviews-listmodels-listelements-mapped-delegates-data-in-q"]link[/URL], though not exactly same query.
Re: Get data from a TextEdit in a ListView
Hi there and thank you for your answer,
Yes I have thought it but how can I assign a value to text1 in my delegate TextEdit?