QML使用MouseArea
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 width: 640 height: 480 Rectangle { width: 40 height: 40 color: "teal" MouseArea { anchors.fill: parent drag.target: parent drag.minimumX: 0 drag.maximumX: 640-parent.width drag.axis: Drag.XAndYAxis } } }
长风破浪会有时,直挂云帆济沧海!
可通过下方链接找到博主
https://www.cnblogs.com/judes/p/10875138.html