qml listview 实现QQ侧滑删除功能

来源:互联网 发布:数控弹簧机编程 编辑:程序博客网 时间:2024/05/21 09:25
ListView{
        width: parent.width
        height: parent.height
        anchors.fill: parent
        model:50
        delegate:Flickable {
            width: parent.width; height: 200
            contentWidth: parent.width*1.4; contentHeight: 200
            boundsBehavior:Flickable.StopAtBounds //该属性设置过后,边界不会被拉出
            Rectangle{
                anchors.fill: parent
                id: rectan
                border.width: 1
                border.color: "black"
                width: parent.width*1.4
                height: 50
                Text {
                    id: name
                    anchors.centerIn: parent
                    font.pointSize: 16
                    width: parent.width
                    elide: Text.ElideRight
                    text: index+"dkasjfkajsdf凯撒减肥的卡坚实的发卡萨丁法卡斯打发"
                    color: "red"
                }
                Rectangle{
                    id: testbtn
                    height: parent.height
                    width: parent.width*0.28
                    color: "red"
                    anchors.right: parent.right
                    Text {
                        anchors.centerIn: parent
                        text: qsTr("删除")
                        color: "#ffffff"
                    }
                    MouseArea{
                        anchors.fill: parent
                        onClicked: {
                            console.log("mouse isclick")
                        }
                    }
                }
            }
        }
    }
1 0
原创粉丝点击