QML MouseArea MapToItem not position the item correctly
I have a problem with QML, I need to create a Rectangle when I do a double click on MouseArea.
The problem is that the Rectangle appears just below the mouse pointer, never in the exact position.
Can anyone tell what's wrong and how can I solve this problem.
Code:
Rectangle {
id: root
width: 360
height: 360
color: "white"
//Initial Values
property int mousePosX: 0
property int mousePosY: 0
property bool showReservoir: false
MouseArea {
id: drawArea
anchors.fill: parent
onDoubleClicked: {
var pos = mapToItem(drawArea, mouse.x, mouse.y)
drawReservoir(Math.abs(pos.x), Math.abs(pos.y))
}
}
Reservoir {
id: m_nodeReservoir
width: 60
height: 60
}
function drawReservoir(positionX, positionY)
{
m_nodeReservoir.x = positionX
m_nodeReservoir.y = positionY
m_nodeReservoir.visible = true
}
}
Thanks!!
Re: QML MouseArea MapToItem not position the item correctly
How does "just below" manifest itself?