QML 窗口失去焦点、任务栏图标隐藏

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/llmys/article/details/85013671

1.窗口失去焦点隐藏
对于ApplicationWindow使其失去焦点隐藏,通过以下即可:

ApplicationWindow {
    id: root
	onActiveFocusItemChanged: {
        if (!activeFocusItem) {
            root.visible = false
        }
    }
}

2.关闭应用程序后关闭任务栏托盘(效果也不是很好)
系统托盘,应用程序退出时,隐藏系统托盘。有时候应用程序关闭了,系统托盘图标没有被关闭,需要鼠标移过去之后才能关闭;此时需要响应 QCoreApplication的aboutToQuit()即可;
在这里插入图片描述
3.设置QWindow窗口图标不在任务栏中显示
使用Window的库函数
在这里插入图片描述
QML中设置flags为Qt.Tool | Qt.X11BypassWindowManagerHint,如下
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/llmys/article/details/85013671
QML