在qml文档中有一个拖放示例。
我已经添加了两行代码,分别是"onDropped"和"onEntered"。 当拖动小矩形时,"onEntered"会被触发,但我无法让"onDropped"触发。
我该怎么做才能让它触发?
import QtQuick 2.0
Item {
width: 200; height: 200
DropArea {
x: 75; y: 75
width: 50; height: 50
onDropped: console.log("dropped")
onEntered: console.log("entered")
Rectangle {
anchors.fill: parent
color: "green"
visible: parent.containsDrag
}
}
Rectangle {
x: 10; y: 10
width: 20; height: 20
color: "red"
Drag.active: dragArea.drag.active
Drag.hotSpot.x: 10
Drag.hotSpot.y: 10
MouseArea {
id: dragArea
anchors.fill: parent
drag.target: parent
}
}
}
我已经添加了两行代码,分别是"onDropped"和"onEntered"。 当拖动小矩形时,"onEntered"会被触发,但我无法让"onDropped"触发。
我该怎么做才能让它触发?