TableView {
id: tableView
width: parent.width
anchors.top: parent.top
anchors.bottom: rectButtons.top
anchors.bottomMargin: mm * 2
clip: true
TableViewColumn {
width: parent.width / 3
role: "company"
title: "供电单位"
resizable: false
}
TableViewColumn {
width: parent.width / 3
role: "stationNumber"
title: "台区编号"
resizable: false
}
TableViewColumn {
width: parent.width / 3
role: "stationName"
title: "台区名称"
resizable: false
}
itemDelegate: Rectangle {
width: tableView.width / 3
height: mm * 10
color: tableView.currentRow === styleData.row ? "#555555" : "lightgray"
Text {
id: contentText
text: styleData.value
width: parent.width
height: parent.height
font.pixelSize: 2.5 * mm
elide: Text.ElideRight
}
MouseArea {
anchors.fill: parent
onPressed: {
tableView.currentRow = styleData.row;
}
onClicked: {
//选中的值
currentCompany = libraryModel.get(styleData.row).company;
currentStationNumber = libraryModel.get(styleData.row).stationNumber;
currentStationName = libraryModel.get(styleData.row).stationName;
}
}
}
headerDelegate: Rectangle {
width: tableView.width / 3
height: mm * 10
color: "#f0f0f0"
Text {
id: headText
text: styleData.value
width: parent.width
height: parent.height
font.pixelSize: 3 * mm
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
}
rowDelegate: Rectangle {
width: meterList.width / 3
height: 10 * mm
color: "#f4f4f4"
}
model: libraryModel
}