我需要在QML中向QML对象发送鼠标事件。例如,
我希望标记为“HERE”的行能够触发
Rectangle
{
id: rect
MouseArea
{
anchors.fill: parent
onClicked: console.log(mouse.x + ', ' + mouse.y)
}
Rectangle
{
x: 0; y: 0; width: 50; height: 50
color: 'red'
onClicked: rect.click(randomX(), randomY()) // <---- HERE
}
}
我希望标记为“HERE”的行能够触发
rect
的点击事件,并将事件传递给MouseArea
。
childAt()
函数是我这种情况的正确解决方案。谢谢! - Dan