【发布时间】:2023-03-20 05:45:01
【问题描述】:
我正在尝试在我的应用中添加一个最小化按钮。
目前我在 Mac Os 中遇到了一些问题。 我在Linux和Win下测试过,没有问题。
有什么想法吗?
Rectangle {
property bool containsMouse: titleBar.mouseX >= x + row.x && titleBar.mouseX <= x + row.x + width && titleBar.containsMouse
anchors.top: parent.top
anchors.bottom: parent.bottom
width: height
color: containsMouse ? "#3665B3" : "#000000"
Image {
anchors.centerIn: parent
source: "../images/minimizeIcon.png"
}
MouseArea {
id: minimizeArea
anchors.fill: parent
onClicked: {
// I can see this in Mac Os but don't work
console.log("its work")
appWindow.visibility = Window.Minimized
}
}
}
appWindow 是我的ApplicationWindow {} // has all my content
有链接看ApplicationWindow:https://github.com/LetheanMovement/lethean-gui/blob/master/main.qml
我尝试对全屏使用相同的代码并且效果很好!
appWindow.visibility = Window.FullScreen
有趣的是:如果我处于全屏模式,我的Windows.Minimized 与Windows.Windowed 具有相同的效果
我正在关注这个文档:https://doc.qt.io/qt-5/qml-qtquick-window-window.html
【问题讨论】:
-
如果您也可以在代码中显示顶部的
Window项,那将是一个好主意。appWindow这里是什么? -
@folibis 我解决了我的问题:我的
appWindows是我的ApplicationWindows{}。 -
好的,但是代码我已经讲过了,为什么不在代码示例中显示
ApplicationWindows? -
@folibis 我添加了 git 的链接,在这里添加很长:D