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

SwipeDelegate: clicked() and released() never emitted for button delegates

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.7.1
    • 5.7.0
    • Quick: Controls 2
    • None

    Description

      When using Button as a left/right delegate, SwipeDelegate steals release events from the Button so its clicked() or released() gets never emitted:

      import QtQuick 2.5
      import QtQuick.Window 2.2
      import QtQuick.Controls 2.0
      
      ApplicationWindow {
          id: window
          width: 360
          height: 360
          visible: true
          
          Shortcut {
              sequence: "Ctrl+Q"
              onActivated: Qt.quit()
          }
      
          ListView {
              anchors.fill: parent
      
              model: ListModel {
                  id: listModel
                  Component.onCompleted: {
                      for (var i = 0; i < 100; ++i)
                          append({text: "SwipeDelegate" + i})
                  }
              }
      
              delegate: SwipeDelegate {
                  id: delegate
                  width: parent.width
                  text: model.text
                  down: pressed || swipe.complete
      
                  Switch {
                      parent: delegate.contentItem
                      anchors.right: parent.right
                      anchors.verticalCenter: parent.verticalCenter
                  }
      
                  swipe.right: Button {
                      id: button
                      x: parent.width - width
                      height: parent.height
                      contentItem: Label {
                          text: "Remove"
                          color: "white"
                          horizontalAlignment: Qt.AlignHCenter
                          verticalAlignment: Qt.AlignVCenter
                      }
                      background: Rectangle {
                          color: button.pressed ? "darkred" : "red"
                      }
                      onPressedChanged: console.log("pressed", pressed)
                      onPressed: console.log("pressed")
                      onCanceled: console.log("canceled")
      
                      // ### onReleased/onClicked never triggered:
                      onReleased: console.log("released")
                      onClicked: { console.log("clicked", index); listModel.remove(index, 1) }
                  }
      
                  ListView.onRemove: SequentialAnimation {
                      PropertyAction { target: delegate; property: "ListView.delayRemove"; value: true }
                      NumberAnimation { target: delegate; property: "height"; to: 0; easing.type: Easing.InOutQuad }
                      PropertyAction { target: delegate; property: "ListView.delayRemove"; value: false }
                  }
              }
          }
      }
      

      Attachments

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

        Activity

          People

            mitch_curtis Mitch Curtis
            jpnurmi J-P Nurmi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes