How to disable rendering in QML WebView?

╄→гoц情女王★ 提交于 2020-01-25 06:01:40

问题


I am currently building an application that makes use of QML WebView (import QtWebKit 3.0). The users need to resize the WebView very often (I am using a QML SplitView), however this leads to the UI to lag extremely whenever the app window is resized. Is there any way to prevent this?


回答1:


Instead of changing the width and height properties change scale property of the WebView.

  • At beginning of the resize save initial values of width and height.
  • On resize don't change width and height. Instead set scale to newWidth divided by width at beginning of the resize.
  • When resize ends set new values of width and height to these properties and set scale to 1.

EDIT: Since you don't have control of width and height properties you can replace WebView with Rectangle with color set to "transparent". Then you can place WebView on Rectangle and watch how width and height of Rectangle are changing.

Now two things.

If you don't know when resize starts and when ends use Timer with interval for example 100ms. Restart Timer and update scale every time width and height of Rectangle changes. When Timer is triggered set real width and height.

If ratio of width and height of Rectangle is not constant use QML object Scale. With it you can change xScale and yScale independently.



来源:https://stackoverflow.com/questions/31896264/how-to-disable-rendering-in-qml-webview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!