1、普通使用
MouseArea {
anchors.fill: parent
hoverEnabled: true//为true才会触发进入信号
onClicked: {
}
onEntered: {
}
onExited: {
}
}
2、可拖曳
import QtQuick 2.9 import QtQuick.Window 2.2 import QtQuick.Controls 2.2 ApplicationWindow { visible: true 640 height: 480 Rectangle { 40 height: 40 color: "teal" MouseArea { anchors.fill: parent drag.target: parent drag.minimumX: 0 drag.maximumX: 640-parent.width drag.axis: Drag.XAndYAxis } } }