如果列表包含字符,我想知道如何显示它。示例:
ListModel {
id: fruitModel
ListElement {
name: "Apple"
cost: 2.45
}
ListElement {
name: "Orange"
cost: 3.25
}
ListElement {
name: "Banana"
cost: 2.45
}
}
UbuntuListView {
objectName: "ubuntuListView"
width: parent.width
height: main.height
model: fruitModel
spacing: units.gu(1)
interactive: false
delegate: ListItem.Subtitled {
showDivider: true
anchors.leftMargin: units.gu(2)
Text {
text: name
color: openFoodFacts.settings.color
}
Label {
anchors { right: parent.right; verticalCenter: parent.verticalCenter}
anchors.rightMargin: 15;
text: cost
}
}
} 如何只展示价格为2.45的水果?
谢谢你的帮助。
对不起,我的英语,我是法国人。
发布于 2016-02-14 20:35:41
假设您使用的是UbuntuListView(在您的示例中您已经声明了一个UbuntuListView),您可以使用一个SortFilterModel。
SortFilterModel {
id: sortedFruitModel
model: fruitModel
filter.property: "cost"
filter.pattern: /2.45/
}然后,在您的ListView集"sortedFruitModel“中作为模型。
https://askubuntu.com/questions/733136
复制相似问题