如何让pyqt应用程序像Rainmeter一样停留在所有窗口的底部? [英] How to make pyqt app stay on bottom of all windows like Rainmeter?
问题描述
我需要让我的窗户保持在底部.我尝试使用 WindowStaysOnBottomHint
但是当点击 Win+D
或 Show 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) 的解决方案.参考 SetWindowPos、SetWindowLong, 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屋!