通常拖动的实现方法如下,会导致在某些系统上窗口“抖动”:
ApplicationWindow {
id: mainWindow
visible: true
width: 640
height: 480
title: qsTr("Window")
flags: Qt.FramelessWindowHint
header: ToolBar {
MouseArea{
anchors.fill: parent
property variant pressedPos: "0,0"
onPressed: {
pressedPos = Qt.point(mouse.x, mouse.y)
}
onPositionChanged: {
var delta = Qt.point(mouse.x - pressedPos.x, mouse.y - pressedPos.y);
mainWindow.x += delta.x;
mainWindow.y += delta.y;
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24