StandardTableView
StandardTableView 表示一个由列和行组成的数据表格。列由
columns 属性定义,每一行是通过 rows 属性设置的
StandardListViewItem 模型。
import { StandardTableView } from "std-widgets.slint";export component Example inherits Window { width: 230px; height: 200px;
StandardTableView { width: 230px; height: 200px; columns: [ { title: "Header 1" }, { title: "Header 2" }, ]; rows: [ [ { text: "Item 1" }, { text: "Item 2" }, ], [ { text: "Item 1" }, { text: "Item 2" }, ], [ { text: "Item 1" }, { text: "Item 2" }, ] ]; }
}slint
与 ScrollView 相同的滚动属性,另外还有:
current-sort-column
Section titled “current-sort-column”int(out)
指示已排序的列,当没有列被排序时为 -1。
columns
Section titled “columns”[struct](in-out)default: []
定义表格列的模型。
StandardTableView { columns: [{ title: "Header 1" }, { title: "Header 2" }]; rows: [[{ text: "Item 1" }, { text: "Item 2" }]];}slint
[[struct]](in-out)default: []
定义表格行的模型。
StandardTableView { columns: [{ title: "Header 1" }, { title: "Header 2" }]; rows: [[{ text: "Item 1" }, { text: "Item 2" }]];}slint
current-row
Section titled “current-row”int(in-out)default: -1
当前活动行的索引。-1 表示未选中任何行,这是 默认值。
sort-ascending(int)
Section titled “sort-ascending(int)”如果应按给定列以升序对模型排序,则发出。
sort-descending(int)
Section titled “sort-descending(int)”如果应按给定列以降序对模型排序,则发出。
row-pointer-event(int, PointerEvent, Point)
Section titled “row-pointer-event(int, PointerEvent, Point)”在任何鼠标指针事件上发出,类似于 TouchArea。参数为与该事件关联的行索引、PointerEvent 本身以及 tableview 内的鼠标位置。
current-row-changed(int)
Section titled “current-row-changed(int)”当当前行因用户修改而发生变化时发出
StandardTableView { columns: [{ title: "Header 1" }, { title: "Header 2" }]; rows: [[{ text: "Item 1" }, { text: "Item 2" }]];
current-row-changed(index) => { debug("Current row: ", index); }}slint
set-current-row(int)
Section titled “set-current-row(int)”通过索引设置当前行,并将其滚动到可见区域。
© 2026 SixtyFPS GmbH