如何让pyqt应用程序像Rainmeter一样停留在所有窗口的底部? [英] How to make pyqt app stay on bottom of all windows like Rainmeter?

查看:58
本文介绍了如何让pyqt应用程序像Rainmeter一样停留在所有窗口的底部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要让我的窗户保持在底部.我尝试使用 WindowStaysOnBottomHint 但是当点击 Win+DShow Desktop 时,应用程序会最小化.

I need to have my window stay on bottom. I tried using WindowStaysOnBottomHint but when Win+D or Show Desktop is clicked the app minimizes.

我研究并发现当使用 Win32 Api SetWindowPos 单击 Show Desktop 时,Rainmeter 会重新排序 Z-index,但我找不到 Python QT 的解决方案.

I researched and found that Rainmeter reorders the Z-index when Show Desktop is clicked using Win32 Api SetWindowPos but I am unable to find a solution for python QT.

请给我解决方案!!

推荐答案

我找到了使用 win32 API for python (Only for windows) 的解决方案.参考 SetWindowPosSetWindowLong, win32gui

I found the solution using win32 API for python (Only for windows) . Refer SetWindowPos, SetWindowLong, win32gui

if sys.platform=='win32':
    from ctypes import windll
    import win32gui,win32con
    win32gui.SetWindowPos(window.winId(),win32con.HWND_BOTTOM, 0,0,0,0, win32con.SWP_NOMOVE | win32con.SWP_NOSIZE  | win32con.SWP_NOACTIVATE )

    hwnd=win32gui.GetWindow(win32gui.GetWindow(windll.user32.GetTopWindow(0),win32con.GW_HWNDLAST),win32con.GW_CHILD);
    win32gui.SetWindowLong(window.winId(),win32con.GWL_HWNDPARENT,hwnd)

window 是 QTWidget 窗口

window is the QTWidget window

这篇关于如何让pyqt应用程序像Rainmeter一样停留在所有窗口的底部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆