Qt QSwipeView动态视图;互动式;“休息”;“当前索引”;结合

Qt QSwipeView动态视图;互动式;“休息”;“当前索引”;结合,qt,qml,Qt,Qml,我正在尝试创建一个SwipeView,其中第一个页面的interactive属性为false,而其他页面的属性为false。我试图实现的效果是在主页上有一个指向其他页面的链接,但其他页面只能返回主页(如iOS设置菜单) 问题是在第一个更改页面之后,currentIndex属性失去绑定,导致SwipeView中断 以下是应用程序输出: qrc:/main.qml:10:5: QML SwipeView: Binding loop detected for property "currentInde

我正在尝试创建一个SwipeView,其中第一个页面的
interactive
属性为false,而其他页面的属性为false。我试图实现的效果是在主页上有一个指向其他页面的链接,但其他页面只能返回主页(如iOS设置菜单)

问题是在第一个更改页面之后,
currentIndex
属性失去绑定,导致SwipeView中断

以下是应用程序输出:

qrc:/main.qml:10:5: QML SwipeView: Binding loop detected for property "currentIndex"
file:///home/rcc/Qt/5.12.6/gcc_64/qml/QtQuick/Controls.2/SwipeView.qml:49:18: QML ListView: Binding loop detected for property "currentIndex"
这里是默认的滑动视图应用程序(QtCreator->New Project->Qt Quick application-swipe)
main.qml

import QtQuick 2.12
import QtQuick.Controls 2.5

ApplicationWindow {
    visible: true
    width: 640
    height: 480
    title: qsTr("Tabs")

    SwipeView {
        id: swipeView
        anchors.fill: parent
        currentIndex: tabBar.currentIndex

        interactive: false

        onCurrentIndexChanged: {
            if (currentIndex === 0) {
                interactive = false
            } else {
                interactive = true
            }
        }

        Page1Form {}

        Page2Form {}
    }

    footer: TabBar {
        id: tabBar
        currentIndex: swipeView.currentIndex

        TabButton {
            text: qsTr("Page 1")
        }
        TabButton {
            text: qsTr("Page 2")
        }
    }
}
要复制错误,请执行以下操作:

  • 单击第2页
  • 向左轻扫
  • 再次单击第2页
有什么解决这个问题的建议吗?

我很抱歉,但现在你应该可以通过推迟分配到交互属性来解决这个问题:

onCurrentIndexChanged: {
    if (currentIndex === 0) {
        Qt.callLater(function() { interactive = false })
    } else {
        Qt.callLater(function() { interactive = true })
    }
}

乍一看,它像一只虫子。请在bugreports.qt.io报告。