gpt4 book ai didi

qt - QML View 中的 Foreach 委托(delegate)

转载 作者:行者123 更新时间:2023-12-04 12:48:59 25 4
gpt4 key购买 nike

是否可以遍历 ListView 的代表?或 GridView使用 foreach或类似的功能?

最佳答案

虽然 Simon 的回答是最佳实践,但要回答所提出的实际问题,您需要遍历 childrenListViewcontentItem像这样:

ListView {
id: list
model: mymodel
delegate: Text {
objectName: "text"
text: name + ": " + number
}
}

for(var child in list.contentItem.children) {
console.log(list.contentItem.children[child].objectName)
}

然后,您可以使用 objectName 或委托(delegate) Item 的任何其他属性进行过滤。

关于qt - QML View 中的 Foreach 委托(delegate),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29329575/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com