Search code examples
htmlc++qtqt5qwebengineview

QWebEngine view loads webpage slowly


I am loading a webpage using the QWebEngineView like

  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");

The local html file looks like

<!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>

The content of the .html file takes forever to render in my QT application. Does anyone know why this is the case? I am also rendering some OpenGL stuff in parallel. I am using QT 5.14.2.


Solution

  • Updating my QT version to QT 5.15.0 made it much faster. Also, I had 3D OpenGLWidgets constantly rendering in parallel in my application. I had to make sure the rendering didn't get updated every frame. This significantly improved the performance of the QWebEngineView.