试验成功 代码如下:
import QtQuick2.2
import QtQuick.Window 2.1
import QtQuick 2.0
Window {
id:window
visible: true
width: 850
height: 500
property int xx: window.x
property int yy: window.y
property int xx1: 0
property int yy1: 0
x:xx;
y:yy
MouseArea { // 拖拽窗体
id: dragArea
anchors.fill: control
hoverEnabled: true
onPressed: {
xx1=mouseX
yy1=mouseY
}
onPositionChanged: {
if(xx1!=0&&yy1!=0){
xx=xx+(mouseX-xx1);
yy=yy+(mouseY-yy1);
}
}
onReleased: {
xx1=0
yy1=0
}
}
/*设置 哪里是 可以拖拽的 区域*/
Rectangle{
id:control x:0;y:0
width:window.width;height: 70
color:"green"
}
/*******去掉qml窗体标题框******/
Component.onCompleted: {
window.flags = 0x0000080
}
}