刷卡上的文字,如何解决?

Text over the Swipe, how to fix?

我的 ListView 包含这样的项目:

我想使用滑动。但是当我添加 SwipeDelegate 我得到这个:

如何在文本上滑动元素?我尝试使用 z 属性,但是 z 我的滑动在打开时没有动画,我无法关闭它。

这是我的代码:

//SomePage.qml:
import QtQuick 2.12
import QtQuick.Controls 2.12

ScrollView {
    ListView {
        id: someListView
        model: SomeItems {}

        delegate: SwipeDelegate {
            width: someListView.width

            Row {
                leftPadding: 5
                width: parent.width

                Image {
                    id: someImg
                    height: 38
                    source: myImage
                    width: height
                }

                Column {
                    leftPadding: 5
                    width: parent.width - someImg.width - 10

                    // Name
                    Text {
                        id: someName
                        text: myCount.toString() + " × " + myName
                    }

                    // Number
                    Text {
                        id: someNumber
                        text: myNumber.toLocaleString(Qt.locale("ru-RU"), "f", 0)
                        anchors.right: parent.right
                        font.pixelSize: 12
                        rightPadding: 5
                    }
                }
            }

            swipe.right: Row {
                anchors.right: parent.right
                height: parent.height

                // Delete button
                Label {
                    text: "\ue800"
                    color: "black"
                    font.family: fontFontello.name
                    height: parent.height
                    padding: 12
                    verticalAlignment: Label.AlignVCenter
                    width: this.height

                    background: Rectangle {
                        color: "lightblue"
                        height: parent.height
                        width: parent.width

                        MouseArea {
                            anchors.fill: parent
                            onClicked: someListView.model.remove(index)
                        }
                    }
                }

                // Hide button
                Label {
                    text: "\ue80a"
                    color: "black"
                    font.family: fontFontello.name
                    height: parent.height
                    padding: 12
                    verticalAlignment: Label.AlignVCenter
                    width: this.height

                    background: Rectangle {
                        color: "lightgray"

                        MouseArea {
                            anchors.fill: parent

                            onClicked: {
                                ...
                                swipe.close()
                            }
                        }
                    }
                }
            }
        }
    }
}

问题是您将 text/image 添加到默认 contentItem 之上,而不是在其中。如果您将 Row 添加到 contentItem,它看起来是正确的,如下所示:

delegate: SwipeDelegate {
    contentItem: Row {
        ...
    }
}