0

I have a Row id:dragList contains a list of items like below:

Item {
    id: dragItem
    Drag.active: dragArea.drag.active
    //Drag.dragType: Drag.Automatic
    MouseArea{
        id: dragArea
        anchors.fill: parent
        drag.target: parent
        onReleased: parent.Drag.drop()
    }
    state: "Init"
    states: [
        State {
            name: "Init"
            ParentChange { target: dragItem; parent: dragList }
        },
        State {
            name: "Settle"
            ParentChange { target: dragItem; parent: dropArea }
        }
    ]
}

And a DropArea id:dropArea .

If drag the item and drop it into the correct dropArea, will relocate it to a certain position inside of dropArea by changing the state to "Settle". otherwise, it will return back to the Row by setting back the state to "Init".

So How to put the dragged out item back to the Row?

I tried PropertyChanges { target: dragMotor; x: undefined} but not work.

JustWe
  • 4,250
  • 3
  • 39
  • 90
  • Once I've answered to the similar question. [Check the answer's example](https://stackoverflow.com/questions/30981404/qml-drag-and-drop-free-positioning/30991733#30991733) and so may be that will be useful. – folibis Mar 13 '18 at 07:05
  • @folibis Thanks, I think my current solution is same as it(without animation), the main problem is I have to layout each item like the Row component and record the original position. Wish it can be layout only by the Row without any positional calculation make the code beautiful. – JustWe Mar 13 '18 at 07:47

0 Answers0