首页 > 解决方案 > QWindow::Minimized 在 Mac Os 上无法按预期工作

问题描述

我试图在我的应用程序中添加一个最小化按钮。

现在我在 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

我尝试对 FullScreen 使用相同的代码并且效果很好!

appWindow.visibility = Window.FullScreen

有趣的是:如果我处于全屏模式,我Windows.Minimized的效果与Windows.Windowed

我关注这个文档:https ://doc.qt.io/qt-5/qml-qtquick-window-window.html

标签: qtqml

解决方案


尝试 appWindow.visibility = Window.Windowed 之前:

    onClicked: {
        // I can see this in Mac Os but don't work
        console.log("its work")
        appWindow.visibility = Window.Windowed
        appWindow.visibility = Window.Minimized
    }

在 ArchLinux 上工作。


推荐阅读