Quero mudar, continuar mudando cursorShape
ao arrastar um item para fora do arquivo MouseArea
.
Como você pode ver no código a seguir, quando mantenho o mouse em current MouseArea
, ele cursorShape
será alterado para DragCopyCursor
. Porém, além disso, se eu mover o mouse para outra área mouseArea, o mouse se tornará ArrowCursor
novamente.
import QtQuick
import QtQuick.Controls
Window {
width: 300
height: 300
visible: true
color: "#1F1F1F"
Column {
anchors.centerIn: parent
Repeater {
model: 2
delegate: Rectangle {
z: mouseArea.drag.active ? 2 : 0
color: "#aaaaaa"
width: 300
height: 50
MouseArea {
id: mouseArea
anchors.fill: parent
drag.target: rec
Binding {
when: mouseArea.drag.active
mouseArea.cursorShape: Qt.DragCopyCursor
}
Rectangle {
id: rec
color: "white"
height: parent.height / 2
width: parent.width / 2
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
Text {
anchors.centerIn: parent
text: "test " + index
color: "black"
}
states: [
State {
when: mouseArea.drag.active
AnchorChanges {
target: rec
anchors.verticalCenter: undefined
anchors.horizontalCenter: undefined
}
}
]
}
}
}
}
}
}
Se você usar
DragHandler
em vez deMouseArea
você pode mantê-locursorShape
durante toda a duração do arrasto. NB paraDragHandler
funcionar, tive que substituir a ancoragem por cálculos explícitos parax
ey
: