QWebView/QWebPage 是在单独的线程中还是在主/gui 线程中下载内容?

发布于 2024-09-27 15:00:46 字数 34 浏览 3 评论 0原文

如果没有,那么我如何显式强制它在单独的线程中异步下载?

If it doesn't, then how can I explicitly force it to download asynchronously in a separated thread?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

任性一次 2024-10-04 15:00:46

根据 文档 QWebView::setHtml()

Sets the content of the web view to the specified html.
External objects such as stylesheets or images referenced in the HTML document are located relative to baseUrl.
The html is loaded immediately; external objects are loaded asynchronously.

QWebView::setContent() 也是如此。因此,原始 HTML 在主线程中加载,任何其他引用(图像、样式表等)在单独的线程中异步加载。

根据经验,我可以看出 QWebView::setUrl() 也异步加载,使用网络管理器等待原始 HTML,这将依次加载其他引用,也是异步的。据我所知,没有办法强制QWebView同步动作。

According to the documentation for QWebView::setHtml():

Sets the content of the web view to the specified html.
External objects such as stylesheets or images referenced in the HTML document are located relative to baseUrl.
The html is loaded immediately; external objects are loaded asynchronously.

Same thing goes for QWebView::setContent(). Therefore, the raw HTML is loaded in the main thread, and any other references (images, stylesheets, etc.) are loaded asynchronously in a separate thread.

From experience, I can tell that QWebView::setUrl() also loads asynchronously, using a network manager to wait for the raw HTML, which will in turn load the other references, also asynchronously. As far as I know, there is no way to force QWebView to act sychcronously.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文