在去掉窗口标题栏后窗口会失去鼠标拖动效果,所以需要自己添加拖动效果。
实现代码:
ApplicationWindow {
id: mainWindow
visible: true
width: 900
height: 600
title: qsTr("Hello World")
flags: Qt.Window | Qt.FramelessWindowHint //去标题栏
property int mainWindowX //用来存储主窗口x坐标
property int mainWindowY //存储窗口y坐标
property int xMouse //存储鼠标x坐标
property int yMouse //存储鼠标y坐标
MouseArea { //为窗口添加鼠标事件
anchors.fill: parent