【发布时间】:2022-10-23 18:25:48
【问题描述】:
如何在无框窗口中返回调整边框大小的逻辑?
QML 中的代码:
import QtQuick
import QtQuick.Controls 2.5
import Qt5Compat.GraphicalEffects
import NR 1.0
Window {
id: mainWindow
width: 640
height: 720
visible: true
title: qsTr("Hello World")
flags: Qt.Window | Qt.FramelessWindowHint
color: "transparent"
// (1)
MouseArea {
id: bottomArea
height: 5
anchors {
bottom: parent.bottom
left: parent.left
right: parent.right
}
cursorShape: Qt.SizeVerCursor
onPressed: {
previousY = mouseY
}
onMouseYChanged: {
var dy = mouseY - previousY
mainWindow.setHeight(mainWindow.height + dy)
}
}
// Some code of another Items here
}
我在左侧尝试了这段代码:
MouseArea {
id: leftSideMouseArea
anchors.fill: parent
property point lastMousePos: Qt.point(0, 0)
onPressed: { lastMousePos = Qt.point(mouseX, mouseY); }
onMouseXChanged: mainWindow.width += (mouseX + lastMousePos.x)
}
我将此代码放在 (1) 位置,但它不起作用 - 单击(不移动)窗口调整为正确大小并且应用程序崩溃并出现错误:
QQuickPaintedItem::textureProvider: 只能在 暴露窗口的渲染线程
你能帮助我吗?
谢谢!
【问题讨论】: