我正在开发一个应用程序,需要一个小功能:我必须能够将一个对象拖到另一个对象上,并且其中至少一个对象应该注意到它们相交了。 因此,问题在于其中一个项必须接受 onEntered 信号事件,即使鼠标从外部按下也是如此。
例如:
import QtQuick 1.0
Rectangle{
id: base
width: 500
height: 500
MouseArea{ //Even without this mousearea I don't get what i want.
anchors.fill: parent
//onPressed:{console.log("big")}
}
Rectangle{
id: t
width: 100
height: 100
color: "red"
MouseArea{
anchors.fill: parent
hoverEnabled: true
onPressed:{console.log("little-press")}
onEntered:{console.log("little-enter")}
drag.target: t
}
}
}
我希望的是在红色正方形区域外按下鼠标按钮并移动它,但不释放该按钮。当鼠标经过红色矩形时,我希望发出onEntered信号。我不明白为什么没有发出信号,因为onEntered只关心鼠标是否在mouseArea内,而不关心按钮。
有任何想法吗?
非常感谢。