查看完整版本: [-- zhengtianzuo系列-Qml上拉下拉刷新 --]

QTCN开发网 -> Qt代码秀 -> zhengtianzuo系列-Qml上拉下拉刷新 [打印本页] 登录 -> 注册 -> 回复主题 -> 发表主题

zhengtianzuo 2017-11-17 13:49

zhengtianzuo系列-Qml上拉下拉刷新

当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()
                }
            }
        ]
    }
```



需要完整代码请访问 QtQuickExamples

big_mouse 2020-04-23 09:24


查看完整版本: [-- zhengtianzuo系列-Qml上拉下拉刷新 --] [-- top --]



Powered by phpwind v8.7 Code ©2003-2011 phpwind
Gzip disabled