在QML中,可以通过设置TableViewColumn的属性来设置文字颜色和背景颜色。
设置文字颜色可以使用Text的color属性,设置背景颜色可以使用Rectangle的color属性。
示例:
TableView {
// ...
TableViewColumn {
role: "name"
title: "Name"
width: 100
delegate: Item {
width: parent.width
height: parent.height
Text {
text: model.name
color: "red" // 设置文字颜色为红色
}
}
}
TableViewColumn {
role: "age"
title: "Age"
width: 100
delegate: Item {
width: parent.width
height: parent.height
Rectangle {
width: parent.width
height: parent.height