zhiyiYo / PyQt-Fluent-Widgets

A fluent design widgets library based on C++ Qt/PyQt/PySide. Make Qt Great Again.
https://qfluentwidgets.com
GNU General Public License v3.0
4.99k stars 464 forks source link

[Bug]: FramelessWebEngineView加载url很慢 #871

Closed zzycrisis closed 2 months ago

zzycrisis commented 2 months ago

What happened?

我使用高德地图api绘制一个3D地图的html,但无法很快加载出地图,需要刷新很多次才会依次出现组件、地图,这个html中使用了channel进行通信,这个会影响到显示效果吗,使用QWebEngineView时可以正常显示html,但是fluentWindows的导航栏会出现黑影。

Operation System

win11

Python Version

3.9

PyQt/PySide Version

PyQt5

PyQt/PySide-Fluent-Widgets Version

v1

How to Reproduce?

image image 效果如上所示

Minimum code

class Widget(QFrame):

    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.setObjectName("homeInterface")
        #self.webView = QWebEngineView(self)
        self.webView = FramelessWebEngineView(self)
        self.webView.load(QUrl.fromLocalFile("D:/python/pyQt/test.html"))
        # 增加一个通信中需要用到的频道
        self.channel = QWebChannel()
        self.printer = Printer()# 通信过程中需要使用到的功能类
        # 将功能类注册到频道中,注册名可以任意,但将在网页中作为标识
        self.channel.registerObject("printer", self.printer)
        self.webView.page().setWebChannel(self.channel)
        self.vBoxLayout = QVBoxLayout(self)
        self.vBoxLayout.setContentsMargins(0, 40, 0, 0)
        self.vBoxLayout.addWidget(self.webView)
    def load_url(self,url):
        print(url)
        self.webView.load(QUrl.fromLocalFile(url))
zhiyiYo commented 2 months ago

云母效果的问题,解决方案看官网文档:

https://qfluentwidgets.com/zh/pages/components/fluentwindow

zzycrisis commented 1 month ago

那请问加载url很慢应该怎么解决呢?我认为加载得慢可能是因为FramelessWebEngineView没那么高效,所以换成了QWebEngine,但现在不能替换的话应该怎么快速显示html界面呢?期待您的回复!