Using Qt C++ QWebView causes the GUI to run slowly

2019-05-22 12:49发布

问题:

When the page loads through QWebView I've noticed that other elements of the program are beginning to run slowly, specifically the GUI.

What is the best solution for addressing this problem?

回答1:

I can't say I've ever had any appreciable slowdown of the rest of a user interface when using QWebView, even on quite underpowered SBCs. I wonder if there's something else going on that's slowing you down.

Are you getting this problem with all pages you load, or just certain ones?

One idea: you can access the settings object (an instance of QWebSettings) for your QWebView using QWebView::settings(). I'd recommend disabling JS to start with (QWebSettings::setAttribute(JavascriptEnabled, false)), just to see if you're being slowed down by any scripts running behind the page you're trying to display.



回答2:

I have the same issue, and it's related to having multiple QWebViews visible (in my case 2-3) and having JavaScript-based elements that are slow to render (such as Raphael elements or a ckeditor document). Since QWebKit must be run from the main thread, any slowdowns in rendering the web page will slow down the rest of the GUI user interaction. I'm currently not aware of any way to solve this. It's disappointing that QWebView cannot be put into another thread.



标签: c++ qt qwebview