当ListView拉动到一定位置的时候 就需要出现Loading
然后加载数据进行刷新
所以我们通过states来进行拉动位置的判断
ListView {
id: listView
width: parent.width
height: parent.height
model: listModel
delegate: Rectangle{
height: 24
width: parent.width
border.color: "#AAAAAA"
border.width: 1
Text {
font.family: "microsoft yahei"
font.pixelSize: 15
anchors.centerIn: parent
text: name + ": " + number
}
}
states: [
State {
id: downRefresh
name: "downRefresh"; when: (listView.contentHeight > 0) && (listView.contentY > (listView.contentHeight - root.height + nPullHeight))
StateChangeScript {
name: "funDownRefresh"
script: funDownRefresh()
}
},
State {
id: upRefresh
name: "upRefresh"; when: (listView.contentY < -nPullHeight)
StateChangeScript {
name: "funUpRefresh"
script: funUpRefresh()
}
}
]
}
show.gif
需要完整代码请访问QtQuickExamples
网友评论