【问题标题】:QWebEngine view loads webpage slowlyQWebEngineview 加载网页缓慢
【发布时间】:2021-09-09 18:46:33
【问题描述】:

我正在使用QWebEngineView 加载网页

  web_engine_view = new QWebEngineView();
  QWebChannel* channel = new QWebChannel(web_engine_view->page());
  web_engine_view->page()->setWebChannel(channel);
  channel->registerObject(QString("my_object"), my_object);
  m_web_engine_view->load("path/to/local/html");

本地html文件的样子

<!DOCTYPE html>
<meta charset="utf-8">

<div id="my_div" style="width: 100%; height: 400px"></div>

<script type="text/javascript" src="qrc:///qtwebchannel/qwebchannel.js"> 
</script>
<script>
    new QWebChannel(qt.webChannelTransport, function (channel) {

       let jsobject = channel.objects.my_object;
       let json_string = jsobject.data;

       // do stuff with the json string

    });
</script>

.html 文件的内容需要很长时间才能在我的 QT 应用程序中呈现。 有谁知道为什么会这样?我也在并行渲染一些 OpenGL 的东西。我正在使用 QT 5.14.2。

【问题讨论】:

标签: html c++ qt qt5 qwebengineview


【解决方案1】:

将我的 QT 版本更新到 QT 5.15.0 使其速度更快。此外,我的应用程序中不断并行渲染 3D OpenGLWidgets。我必须确保渲染不会每帧都更新。这显着提高了 QWebEngineView 的性能。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-12
    • 2015-03-15
    • 1970-01-01
    • 2015-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多