【发布时间】:2020-10-14 17:21:34
【问题描述】:
表1
Item {
id: control
TableView {
id: table1
delegate: Rectangle {
color: control.selected === row ? "pink" : "white"
border.color: control.selected === row?"lightblue":"transparent"
border.width: 2
Text {
text: display
color: "black"
}
}
}
}
表2
TableView{
id :tableView
headerDelegate:Rectangle{
color : "transparent"
Text
{
text: styleData.value
}
}
rowDelegate: Rectangle {
color : styleData.selected ? "pink" : "white"
border.color: styleData.selected ?"lightblue":"transparent"
}
itemDelegate: Rectangle{
color : "transparent"
Text {
color : "black"
text: styleData.value
}
}
style: TableViewStyle{
backgroundColor : "transparent"
}
}
}
效果
在 QtQuick Controls 1.0 版中使用 rowDelegate 很容易。 我不知道在选择行时为行项目设置边框颜色。 好像border-color只能为一行中的每一项设置。
【问题讨论】:
标签: qt qml tableview qtquickcontrols