import QtQuick 2.15
import QtQuick.Window 2.15
// 可移动窗口
Window {
id: rootWindow
visible: true
width: 900
height: 600
title: qsTr("Hello World")
flags: Qt.FramelessWindowHint | Qt.Dialog | Qt.WindowStaysOnTopHint
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.LeftButton
property point clickPos: "0,0"
onPressed: {
clickPos = Qt.point(mouse.x,mouse.y)
// 不能mouse.accepted = false
}
onPositionChanged: {
var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y)
rootWindow.setX(rootWindow.x+delta.x)
rootWindow.setY(rootWindow.y+delta.y)
}
}
}
accepted : bool
Setting accepted to true prevents the mouse event from being propagated to items below this item.
Generally, if the item acts on the mouse event then it should be accepted so