Table1
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"
}
}
}
}
Table2
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"
}
}
}
effect
It is easy to make with rowDelegate at QtQuick Controls version 1.0 . I have no idea for setting border-color for row item while row selected. It seems border-color can only be set for each item in a row.
I made it with other four rectangles finally :)
like this:
Rectangle { anchors.top: parent.top; height: item_table.borderWidth; width: parent.width; color: isSelect()?borderColor:"transparent"}
Rectangle { anchors.bottom: parent.bottom; height: item_table.borderWidth; width: parent.width; color: isSelect()?borderColor:"transparent"}
Rectangle { anchors.left: parent.left; height: parent.height; width: item_table.borderWidth; color: borderColor; visible: (isSelect()&&column === 0) }
Rectangle { anchors.right: parent.right; height: parent.height; width: item_table.borderWidth; color: borderColor; visible: (isSelect()&&column === tableView.columns - 1) }