StandardListView
import { StandardListView, VerticalBox } from "std-widgets.slint";export component Example inherits Window { width: 200px; height: 200px;
VerticalBox { StandardListView { model: [ { text: "Blue"}, { text: "Red" }, { text: "Green" }, { text: "Yellow" }, { text: "Black"}, { text: "White"}, { text: "Magenta" }, { text: "Cyan" }, ]; } }
}slint
类似 ListView,但带有默认委托和一个 model 属性。
与 ListView 相同,另外还有:
current-item
Section titled “current-item”int(in-out)default: -1
当前活动项的索引。-1 表示未选中任何项,这是默认值
struct StandardListViewItemdefault: []
模型。
StandardListView { model: [{ text: "Blue" }, { text: "Red" }, { text: "Green" }];}slint
set-current-item(int)
Section titled “set-current-item(int)”通过指定的索引设置当前项,并将其滚动到可见区域。
current-item-changed(int)
Section titled “current-item-changed(int)”当当前项因用户修改而发生变化时发出
StandardListView { model: [{ text: "Blue" }, { text: "Red" }, { text: "Green" }]; current-item-changed(index) => { debug("Current item: ", index); }}slint
item-pointer-event(int, PointerEvent, Point)
Section titled “item-pointer-event(int, PointerEvent, Point)”在任何鼠标指针事件上发出,类似于 TouchArea。参数为与该事件关联的项索引、PointerEvent 本身以及 listview 内的鼠标位置。
© 2026 SixtyFPS GmbH