• 3285阅读
  • 1回复

zhengtianzuo系列-Qml上拉下拉刷新 [复制链接]

上一主题 下一主题
离线zhengtianzuo
 

只看楼主 正序阅读 楼主  发表于: 2017-11-17
当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
博客地址: https://blog.csdn.net/zhengtianzuo06
Github: https://github.com/zhengtianzuo
个人产品: https://github.com/zhengtianzuo/Silk
产品网站: http://www.camelstudio.cn
离线big_mouse

只看该作者 1楼 发表于: 2020-04-23
快速回复
限100 字节
 
上一个 下一个