1

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?

2
  • You'd probably need to profile it and see where the time is spent. Commented Aug 8, 2015 at 18:33
  • @KubaOber I did that and the drop in frame rate, happens exactly when I resize the SplitView (changing the width of the WebView) when its updateLayout() and moveHandle() functions are triggered. Commented Aug 8, 2015 at 18:41

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

5 Comments

That is a good idea. However since I said I am using a SplitView, I don't have control over the height and width property.
@daljit97 I think that changing scale or using Scale object is all you need. For more information see my edited answer. If you are still not satisfied please provide simple example of code you want to work without lag.
I followed your approach and it works, however the WebView becomes invisible when scaling. It is much better then before though, thank you.
@daljit97 Strange. It can look stretched unnaturally but it shouldn't be invisible.
@daljit97 You certainly have full control of the properties, you just need to interpose some of your own code between the container and the view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.