0
在下面的代碼一行可見的TableView:QML:只有行和項目代表
Rectangle{
width: { parent==null ? 640: parent.width }
height: { parent==null ? 480: parent.height }
Image {
id: mainBackground
anchors.fill: parent
source: "qrc:///wallDiscoveryBackground"
fillMode: Image.PreserveAspectFit
TableView {
id: wallDiscoveryTable
anchors.margins: parent.width * 0.6
width: parent.width
clip: true
model: discoveredWallsTableModel
TableViewColumn { role: "name"; width: 240; title: "Name" }
TableViewColumn { role: "ipAddress"; width: 240; title: "IP Address" }
TableViewColumn { role: "status"; width: 240; title: "Status" }
rowDelegate: wallDiscoveryRowDelegate //comment out
itemDelegate: wallDiscoveryItemDelegate //comment out
}
Component {
id: wallDiscoveryRowDelegate
Rectangle {
width: wallDiscoveryTable.width
height: 640
}
}
Component {
id: wallDiscoveryItemDelegate
Text {
anchors.verticalCenter: parent.verticalCenter
color: styleData.textColor
text: styleData.value
}
}
}
}
如果我註釋掉線設置行和項目代表(我已經標有「//註釋掉」線),表格呈現的很好,表明我指定的模型是正確的。但是,當我設置行和項目代表時,我只獲取表格的第一行。
有人可以指出我在第二種情況(與行和物品代表)有什麼不對嗎?
你是對的!我現在感到很蠢。 :P – balajeerc 2014-09-13 06:47:07