import QtQuick 2.1 import QtQuick.Dialogs 1.0 Rectangle { id: container width: 600; height: 600 color: "blue" Rectangle { id: rect width: 80; height: 80 color: "red" MouseArea { anchors.fill: parent drag.target: rect drag.minimumX: 0 drag.maximumX: container.width - rect.width drag.minimumY: 0 drag.maximumY: container.height - rect.height drag.threshold: 20 } } Text { text: "x:" + rect.x + " y:" + rect.y + " threshold:" + 20; font.pixelSize: 20 anchors.bottom: container.bottom } }