【问题标题】:QWindow::Minimized don't work as expected on Mac OsQWindow::Minimized 在 Mac Os 上无法按预期工作
【发布时间】: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.MinimizedWindows.Windowed 具有相同的效果

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

【问题讨论】:

  • 如果您也可以在代码中显示顶部的Window 项,那将是一个好主意。 appWindow 这里是什么?
  • @folibis 我解决了我的问题:我的appWindows 是我的ApplicationWindows{}
  • 好的,但是代码我已经讲过了,为什么不在代码示例中显示ApplicationWindows
  • @folibis 我添加了 git 的链接,在这里添加很长:D

标签: qt qml


【解决方案1】:

之前尝试过 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 上工作。

【讨论】:

  • 我的代码在 Linux 上运行,我的问题在 Mac Os 上。 Tks 的帮助,但解决方案对我不起作用。 :(
  • 这取决于桌面环境...在我的 Ubuntu 上没有 Windowed 也可以正常工作,但在 Arch 上没有 Windowed 就无法工作。我认为这是某种 qml 错误
  • 找到 Mac Os 解决方案时会通知您。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-08-14
  • 2019-01-15
  • 2014-10-20
  • 2021-08-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多