import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
Window {
id: window
width: 430
height: 330
visible: true
title: qsTr("Positioner")
flags: Qt.FramelessWindowHint | Qt.Window
color: "#00000000"
Rectangle{
anchors.fill: parent
color: "gray"
radius: 2
MouseArea {
property point clickPos: "0,0"
anchors.fill: parent
acceptedButtons: Qt.LeftButton
onPressed:(mouse)=>{
clickPos = Qt.point(mouse.x,mouse.y)
}
onPositionChanged:(mouse)=>{
var delta = Qt.point(mouse.x-clickPos.x, mouse.y-clickPos.y)
window.setX(window.x + delta.x)
window.setY(window.y + delta.y)
}
}
}
}
- window.flags中, Qt.Wiindow的作用是,让窗口在任务栏中有显示
- acceptedButtons: Qt.LeftButton,只接收左键
效果图