QML:showMinimized()后的渲染问题

发布于 2024-11-16 11:26:46 字数 789 浏览 0 评论 0原文

在 QML 中渲染时遇到以下问题。我已经实现了“最小化窗口”按钮:

Image {
    source: "minimize.png"
    scale: mouse.pressed ? 0.8 : 1.0
    smooth: mouse.pressed

    MouseArea {
        id: mouse
        anchors.fill: parent
        anchors.margins: -5
        onClicked: {
            console.log("MinimizeButton clicked");
            viewer.showMinimized();
        }
    }
}

其中“查看器”是从 QDeclarativeView 继承的对象,它代表主应用程序窗口。 当用户单击鼠标时,按钮会缩小,并且窗口已最小化。但是当窗口恢复时按钮保持收缩状态。 尝试添加每 1 秒打印一次“mouse.pressed”的计时器:

Timer {
    repeat: true
    interval: 1000
    running: true
    onTriggered: {
        console.log("mouse.pressed =",mouse.pressed);
    }
}

它总是打印未按下的鼠标。但按钮缩放为 0.8,而不是 1.0。 “viewer.showMinimized()”似乎是有罪的:如果被注释掉,按钮将呈现正常。

有什么解决问题的建议吗?

Encountered the following problem with rendering in QML. I have implemented the 'minimize window' button:

Image {
    source: "minimize.png"
    scale: mouse.pressed ? 0.8 : 1.0
    smooth: mouse.pressed

    MouseArea {
        id: mouse
        anchors.fill: parent
        anchors.margins: -5
        onClicked: {
            console.log("MinimizeButton clicked");
            viewer.showMinimized();
        }
    }
}

where 'viewer' is the object inherited from QDeclarativeView which represents the main application window.
The button shrinks when user clicks the mouse onto it and window has been minimized. But button stays shrinked when window is restored.
Tried to add the timer which prints 'mouse.pressed' every 1 sec:

Timer {
    repeat: true
    interval: 1000
    running: true
    onTriggered: {
        console.log("mouse.pressed =",mouse.pressed);
    }
}

It always prints mouse not pressed. But button is scaled to 0.8, not 1.0.
"viewer.showMinimized()" appears to be guilty: button is rendered OK if it is commented out.

Any suggestions to solve the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文