我有ListView,我想在其中的滚动区域顶部放置元素
我尝试通过添加页脚进行操作
并且我尝试计算页脚高度,但得到错误: qrc:/main.qml:28:17:QML项目:检测到属性“ height”的绑定循环
import QtQuick 2.3
import QtQuick.Controls 1.2
ApplicationWindow {
visible: true
width: 640
height: 480
ListView {
id: list
anchors.fill: parent
model: 50
cacheBuffer:1000
delegate: Rectangle {
id: dg
property int yoff: Math.round(dg.y - list.contentY)
property bool isFullyVisible: (yoff > list.y && yoff + height < list.y + list.height)
border.color: Qt.darker(color, 1.2)
color: isFullyVisible ? "#ccffcc" : "#fff"
height: /*Math.random() **/ 100
width: parent.width
Text {text: "Fully visible: " + isFullyVisible + " dg.y: " + dg.y + " list.contentY: " +
list.contentY + " list.y: " + list.y + " list.height: " + list.height +
" dg.height: " + dg.height
anchors.centerIn: parent}
}
footer: Item {
id: ft
function calculateFooterHeight(){
var sumHeightOfVisibleElements = 0
for(var child in list.contentItem.children) {
sumHeightOfVisibleElements += list.contentItem.children[child].height
}
return sumHeightOfVisibleElements
}
width: parent.width
height: list.height - calculateFooterHeight()
}
}
}
如何解决此问题?