Below code allows the small red coloured rectangle to be dragged in an area which is a rectangle defined by minimum and maximum drag values.
I want it to go on only up till the boundary of the parent rectangle whose radius is 100 which means that it is now a circle.
How to make an item drag inside a circle in QML?
Window {
width: 200; height: 200; visible: true
Rectangle
{
x: 10; y: 10
width: 200; height: 200
radius: 100
color: "blue"
Rectangle {
x: 10; y: 10
width: 20; height: 20
color: "red"
MouseArea
{
id: dragArea
anchors.fill: parent
drag.target: parent
drag.minimumX : 20
drag.maximumX : 150
drag.minimumY : 20
drag.maximumY : 150
}
}
}
}
Math.pow((x - center_x),2) + Math.pow(y - center_y,2)) < Math.pow(r,2)
– folibis