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

Add "pressed" property to Flickable

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 5.12.3
    • None
    • Linux/X11, Windows

    Description

      import QtQuick 2.12
      import QtQuick.Controls 2.5
      
      Item {
          id: root
          width: 600
          height: 600
      
          ListView {
              id: list
      
              anchors.fill: parent
              clip: true
              anchors.margins: 100
              model: 20
              spacing: 20
              currentIndex: button.index
      
              preferredHighlightBegin: height / 2 - 50
              preferredHighlightEnd: preferredHighlightBegin + 100
              highlightRangeMode: ListView.StrictlyEnforceRange
      
              onMovementStarted: timer.stop
              onMovementEnded: timer.start()
      
              onCurrentIndexChanged: console.warn("CurrentIndex", currentIndex)
      
              delegate: Rectangle {
                  width: parent.width
                  height: 100
                  color: "green"
                  Text {
                      anchors.centerIn: parent
                      text: index
                      font.pixelSize: 50
                  }
              }
          }
      
          Button {
              id: button
              property int index: 5
              onClicked: index = (index + 1) % 20
              text: index
              font.pixelSize: 50
          }
      
          Timer {
              id: timer
              interval: 2000
              onTriggered: {
                  console.warn("triggered")
                  list.currentIndex = Qt.binding(function(){return button.index})
              }
          }
      }
      

      The list.currentIndex is binding to button.index. The user can interact with the ListView, but after 2000 ms, it should return to the button.index. But if during a call _list.currentIndex = Qt.binding(function()

      {return button.index})_ the user press on the ListView and does not move the mouse, the currentIndex will change but the ListView will not scroll to the currentIndex. And after that I can’t determine when the user released the mouse and the call _list.currentIndex = Qt.binding(function(){return button.index}

      )_ will not have any results. Could you add a pressed property to Flickable?
      So that I can use it like that:

      ListView {
          ...
          onPressedChanged: {
              if (pressed)
                  timer.stop()
              else
                  timer.start()
          }
      }
      

      Or maybe you can offer another solution to this problem?

      Attachments

        1. taphandler.qml
          1 kB
          Shawn Rutledge

        Issue Links

          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
              evgeniy_kolchin Kolchin Evgeny
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes