|
萌新求助,怎么将 qt 应用程序嵌入到桌面中呢?就是按 win+D 应用程序会保留在桌面上。
之前搜了教程,c++ 的貌似可以使用 hwnd ,将qt的 hwnd 设置为桌面的hwnd的孩子。来嵌入到桌面中。但是并不能成功。
请问要怎么修改程序呢?
- from PyQt5 import QtWidgets, QtGui
- import win32gui
- import sys
- import ctypes
- app = QtWidgets.QApplication(sys.argv)
- w = QtWidgets.QDialog()
- winid=w.winId()
- b=win32gui.GetDesktopWindow()
- ctypes.pythonapi.PyCapsule_GetPointer.restype = ctypes.c_void_p
- ctypes.pythonapi.PyCapsule_GetPointer.argtypes = [ctypes.py_object, ctypes.c_char_p]
- handle = ctypes.pythonapi.PyCapsule_GetPointer(winid.ascapsule() , None)
- print(handle)
- print(b)
- win32gui.SetParent(handle, b)
- w.show()
- sys.exit(app.exec_())
复制代码
|
|