QML:通过索引访问ListView中的委托项

时间:2015-10-15 01:50:28

标签: qml qt5 qtquick2

我希望从外部按索引访问元素(委托),这是ListView index的一部分。

特别是,我想访问代表中text的{​​{1}}属性。

让我们假设模型:

TextInput

`

我已经在委托中找到了有意义的属性绑定(ListView { id: list model: ListModel { ListElement { label: "1st" } ListElement { label: "2nd" } } delegate: Item { Row { Rectangle { id: box Text { id: _label text: label [..] TextInput { id: _input text: "enter something.." ),从那时起我就可以通过例如property alias input: _input.text来访问输入数据了。 TextInput

但是我仍然很难通过list.currentItem.input访问特定的代理。

index没有帮助,因为它显然是访问模型而不是代理。

如何通过索引访问TextInput-widget的text-property-如(伪代码):list.model.get(i)

0 个答案:

没有答案