【发布时间】:2019-10-21 16:34:44
【问题描述】:
我只是想在我的 QML 文件中创建一个 TableView,就像这样 -
TableView {
id: resultListTableView
anchors.fill: parent
rowDelegate: Rectangle {
color: "#D3D3D3"
height: 30
}
itemDelegate: Rectangle {
width: 100
height: 50
border.color: "#000000"
border.width: 1
Text {
id: textItem
text: styleData.value
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
elide: Text.ElideRight
}
}
headerDelegate: Rectangle {
height: textItem.implicitHeight * 1.2
width: textItem.implicitWidth
color: "lightsteelblue"
Text {
id: textItem
anchors.centerIn: parent
text: styleData.value
elide: Text.ElideRight
}
}
TableViewColumn {
role: "file"
title: "File"
width: resultListTableView.viewport.width * 0.3
movable: false
resizable: false
}
TableViewColumn {
role: "type"
title: "Type"
width: resultListTableView.viewport.width * 0.2
movable: false
resizable: false
}
TableViewColumn {
role: "size"
title: "Size"
width: resultListTableView.viewport.width * 0.2
movable: false
resizable: false
}
TableViewColumn {
role: "path"
title: "Path"
width: resultListTableView.viewport.width * 0.3
movable: false
resizable: false
}
model: ResultListDataModel {}
onDoubleClicked: {
const element = model.get(row)
console.log("Downloading file ", element.file, "of size", element.size)
}
}
此组件是 TabView 的一部分,并在单击相应选项卡时显示。但是,当单击选项卡时,我随机收到一个绑定循环警告:
QML TableView: Binding loop detected for property "__scrollBarTopMargin"
我没有做任何可能导致这个绑定循环的事情,所以我想知道问题出在哪里。有人知道这里发生了什么吗?
【问题讨论】: