Important: Please read the Qt Code of Conduct -

Detect whether Item is Currently being dragged

  • I have a GridView where I can drag items, following the draganddrop example:

    model: DelegateModel {
          delegate: DropArea {
              id: delegateRoot
              width: 80; height: 80
              onEntered: visualModel.items.move(drag.source.visualIndex, icon.visualIndex)
              property int visualIndex: DelegateModel.itemsIndex
              Binding { target: icon; property: "visualIndex"; value: visualIndex }
              Rectangle {
                  id: icon
                  property int visualIndex: 0
                  width: 72; height: 72
                  anchors {
                      horizontalCenter: parent.horizontalCenter;
                      verticalCenter: parent.verticalCenter
                  radius: 3
                  color: model.color
                  Text {
                      anchors.centerIn: parent
                      color: "white"
                      text: parent.visualIndex
                  DragHandler {
                      id: dragHandler
                  Drag.source: icon
                  Drag.hotSpot.x: 36
                  Drag.hotSpot.y: 36
                  states: [
                      State {
                          ParentChange {
                              target: icon
                              parent: root
                          AnchorChanges {
                              target: icon
                              anchors.horizontalCenter: undefined
                              anchors.verticalCenter: undefined

    How can I determine whether the item is at rest in the grid, or displaced through dragging? The reason I need this: The item gets a MouseArea where I want to assign an action to onPressAndHold. However, this action should not be triggered during dragging.

  • Its actually easy:
    check for

Log in to reply