-
Notifications
You must be signed in to change notification settings - Fork 97
QMdiArea加入外部程序窗口后使用体验差的问题 #9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
嵌入外部窗口本身就有很多问题 window = QWindow.fromWinId(hwnd)
widget = QWidget.createWindowContainer(window)
layout.addWidget(widget)
widget.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE, win32con.WS_EX_TOPMOST)
#注意这里
win32gui.SetParent(hwnd, int(self.winId())) |
经过实现,效果还是还是差不多;两个窗口在一起时候 会有出现马赛克的情况,效果丝毫差不多,下面是我的代码,自己又添加一些
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2020/8/15
@author: Irony
@site: https://pyqt5.com , https://github.com/892768447
@email: [email protected]
@file: MdiArea
@description:
"""
import win32con
import win32gui
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QWindow
from PyQt5.QtWidgets import QApplication, QMdiArea, QWidget
class Window(QMdiArea):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
def getWindow(hwnd, _):
# 查找位置
text = win32gui.GetWindowText(hwnd)
cname = win32gui.GetClassName(hwnd)
if cname == 'Notepad':
window = QWindow.fromWinId(hwnd)
widget = QWidget.createWindowContainer(window)
widget.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)
win32gui.SetWindowLong(hwnd, win32con.GWL_STYLE, win32con.WS_EX_TOPMOST)
# 注意这里
win32gui.SetParent(hwnd, int(self.winId()))
self.addSubWindow(widget)
win32gui.EnumChildWindows(0, getWindow, 0)
if __name__ == '__main__':
import sys
import cgitb
cgitb.enable(1, None, 5, '')
app = QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_()) |
你好,我有一个问题想要请教你: 我尝试将外部程序的窗口作为一个子窗口(QMdiSubWindow)加入我的QMdiArea中,我在拖动的窗口时,体验十分的差,如果我加入两个计算器(窗口时)时,移动窗口就会出现花屏的情况;不知道这种情况是因为内存不够引起的,还是子窗口的属性不对; 查看了QT的这两个类的帮助文档,然后百度和查看比较多的教程并没有发现他们有类似的疑问;如果你有相关的经验/解题思路,还请帮忙,谢谢~~
The text was updated successfully, but these errors were encountered: