import QtQuick Window { width: 640 height: 480 visible: true title: qsTr("Hello World") Rectangle { id : target_rect width: 100 height: 100 color: "lightsteelblue" Text { anchors.centerIn: parent text: "drag me" } MouseArea { anchors.fill: parent property real clickx: 0 property real clicky: 0 onPressed: function(mouse) { console.log("Pressed") clickx = mouse.x clicky = mouse.y mouse.accepted = true } onReleased: function(mouse) { console.log("Released") } onPositionChanged: function(mouse) { console.log("PositionChanged", pressed) if (pressed) { target_rect.x += mouse.x - clickx; target_rect.y += mouse.y - clicky; } } hoverEnabled: true } } }