Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-80750

SwipeView with dynamic "interactive" breaks "currentIndex" binding

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.12.6
    • Quick: Controls 2
    • None
    • Linux/Wayland, Linux/X11

    Description

      I'm trying to create a SwipeView where the first page has the interactive property false, while the others have it enabled. The effect that I'm trying to achieve is to have the main page with a link to the others, but the others can only go back to the main page (like the iOS settings menu).

      The issue is that after the first change page, the currentIndex the property loses binding causing the SwipeView to break.

      Here's the application output:

      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"

      and here's the default swipe view application (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
                  }
              }
      
              Rectangle {
                  color: "red"
                  opacity: 0.5
              }
              Rectangle {
                  color: "green"
                  opacity: 0.5
              }
          }
      
          footer: TabBar {
              id: tabBar
              currentIndex: swipeView.currentIndex
      
              TabButton {
                  text: qsTr("Page 1")
              }
              TabButton {
                  text: qsTr("Page 2")
              }
          }
      }
      

      To reproduce the bug:

      • Click on Page 2.
      • Swipe left.
      • Click again on Page 2.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            rcc21 Andrea Ricchi
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes