Qt 我们可以使用PathView创建SwipeView吗?

Qt 我们可以使用PathView创建SwipeView吗?,qt,qml,qqmlapplicationengine,qqmllistproperty,Qt,Qml,Qqmlapplicationengine,Qqmllistproperty,在QML中,滑动视图不是双向的。所以我需要滑动视图 一个代码示例将对我非常有益。 我只需要在视图中保留3个项目&一次只显示一个项目&以任何方式滑动视图时,左元素或右元素都应居中。此代码解决了一半的问题,这就是为什么我发布为答案 import QtQuick 2.0 Item { property alias model: view.model property alias delegate: view.delegate property alias currentInd

在QML中,滑动视图不是双向的。所以我需要滑动视图 一个代码示例将对我非常有益。
我只需要在视图中保留3个项目&一次只显示一个项目&以任何方式滑动视图时,左元素或右元素都应居中。

此代码解决了一半的问题,这就是为什么我发布为答案

import QtQuick 2.0

Item {
    property alias model: view.model
    property alias delegate: view.delegate
    property alias currentIndex: view.currentIndex
    property real itemHeight: 60

    clip: true

    PathView {
        id: view
        anchors.fill: parent
        snapMode: PathView.NoSnap
        pathItemCount: height/itemHeight
        preferredHighlightBegin: 0.5
        preferredHighlightEnd: 0.5
        dragMargin: view.width/5
        path: Path {
            startY: view.width/4; startX:-itemHeight/2 -50
            PathLine { y: view.width/4; x: (view.pathItemCount*itemHeight + 3*itemHeight) }
        }
    }
}
这是我的项目:

Item{
    id:widgetMain
    width :480
    height : 240
    property int  delegateHeight: widgetMain.height
    property int delegateWidth : widgetMain.width
    Spinner {
        id: spinner
        width: parent.width;
        height: parent.height;
        focus: true
        model: ["qrc:/Tile1.qml",
            "qrc:/Tile2.qml"
            ,"qrc:/Tile3.qml"]
        itemHeight: 150

        delegate: Loader {
            width: delegateWidth
            height: delegateHeight
            source: modelData
        }
    }
}
现在,如果我向任何方向滑动,它在视图中只显示1个平铺当我的阻力达到一半时,瓷砖将移除并移到最后

在这里,我想显示一个磁贴正在滑动&第二个磁贴来自后面,就像滑动视图一样


现在你能帮我吗?

你刚才的问题没有得到答案吗?试着创造一些东西,所以如果你遇到问题,就回来。没有人会在这里为您编写代码。我想您的问题是路径。这是误导,因为前景和背景线在同一个位置。当背景线不在屏幕上时,试着画一些圆圈或三角形。