Qt 6中的Qt-WebEngine

Qt WebEngine in Qt 6

Qt 6中的Qt-WebEngine

Thursday March 10, 2022 by Allan Sandfeld Jensen | Comments

​2022年3月10日星期四 艾伦·桑德菲尔德·詹森 | 评论

Qt WebEngine has been out for Qt 6 since 6.2, but I would still like to talk a bit about what is different in WebEngine in Qt 6, and what will change in the Qt 6 time frame.

Qt WebEngine从6.2开始就已经推出Qt 6了,但我仍然想谈一谈Qt 6中WebEngine的不同之处,以及Qt 6的时间框架将发生什么变化。

Releases

发布

There had been talk about splitting WebEngine from the general Qt release. This hasn't happened yet, but we are working on providing a newer WebEngine (6.3) with Qt 6.2 once it hits LTS. That work will also ensure all users can easily use a newer WebEngine with an older Qt 6 version. As is, we do spot testing of newing WebEngine versions with last LTS branch (6.2), so it mostly work, but users could hit conflicts due to untested combinations of changes or settings.

有人曾讨论过将WebEngine从通用的Qt版本中分离出来。这还没有发生,但我们正在努力提供一个更新的WebEngine(6.3)和Qt6.2,因为它长期支持版。这项工作还将确保所有用户都可以轻松使用更新的Web引擎和较旧的Qt 6版本。照目前的情况,我们使用最后一个LTS分支(6.2)对新的WebEngine版本进行了现场测试,所以它基本上可以工作,但用户可能会因为未经测试的更改或设置组合而遇到冲突。

Qt WebEngine 6.3 will be based on Chromium 94, we are currently working on a Chromium 98 rebase, but it is too late for 6.3, and instead go to Qt 6.4, though 6.4 will likely end up with something based on Chromium 100+ once that has been released and rebased upon.

Qt WebEngine 6.3将基于Chromium 94,我们目前正在开发Chromium 98新版,但对于6.3来说为时已晚,转而在Qt 6.4集成,尽管6.4一旦发布并重新基化,很可能会以Chromium 100+为基础。

Qt WebEngine 6.3 is also finally switching to building with python 3 as Chromium finally switched off depending on python 2 late last year.

Qt WebEngine 6.3最终也将切换到使用python 3的构建,因为Chromium最终在去年年底关闭python 2版本。

RHI Support

RHI支持

Qt 6 moved off the OpenGL default rendering to the multi-backend RHI rendering framework. Qt WebEngine is however relying on Chromium which is still using OpenGL internally, and QQuickWidget which still only supports the OpenGL and software backends. This means for now WebEngine only works with OpenGL or software, and will try to set the default rendering backend to OpenGL when loaded, and if failing that, use software rendering. A patchset exists to enable Vulkan rendering, but the uneven quality of Vulkan drivers has made it hard to test, and since it isn't default anywhere of lower priority, users interested are welcome to test the change, it is QML-only since the widgets code uses QQuickWidget as previously mentioned. We are looking into solutions to be able to use hardware accelerated rendering also with Metal and D3D11 backend, and fix the dependency on QQuickWidget.

​Qt 6将OpenGL默认渲染移到了多后端RHI渲染框架。然而,Qt WebEngine依靠的是仍然在内部使用OpenGL的Chromium和仍然只支持OpenGL和软件后端的QQuickWidget。这意味着目前WebEngine仅适用于OpenGL或软件,加载时将尝试将默认渲染后端设置为OpenGL,如果失败,则使用软件渲染。有一个补丁集可以启用Vulkan渲染,但Vulkan驱动程序的质量参差不齐,这使得测试变得很困难,而且由于它不是优先级较低的任何地方的默认设置,欢迎感兴趣的用户测试更改,它是QML,因为widgets代码使用了前面提到的QQuickWidget。我们正在寻找解决方案,以便能够在Metal和D3D11后端使用硬件加速渲染,并修复对QQuickWidget的依赖。

API Changes

API更改

WebEngine had many duplicated APIs in Qt 5 in both Widgets and QML. In Qt 6 many of those APIs have been unified into classes in Qt WebEngineCore. In most case this makes very little difference to users, unless you had the module name in the C++ include lines. Most of the new core API has been moved from WebEngineWidgets into WebEngineCore, but a few has been moved from WebEngineQuick to WebEngineCore, and provides new API for C++ users.

WebEngine在Qt5中的Widgets和QML中都有许多重复的API。在Qt 6中,这些API中的许多已经统一到Qt WebEngineCore中的类中。在大多数情况下,这对用户来说几乎没有什么差别,除非您在C++包含行中有模块名。大多数新的核心API已经从WebEngineWidgets迁移到WebEngineCore,但是一些已经从WebEngineQuick迁移到WebEngineCore,并为C++用户提供了新的API。

The QML module is now called WebEngineQuick instead of WebEngine, to disambiguate it from the super module.

QML模块现在被称为WebEngineQuick,而不是WebEngine,以消除它与超级模块之间的歧义。

Some methods have been introduced to avoid users having to derive from QWebEnginePage. For instance work done QWebEnginePage::createWindow() can now also be done by handling the QWebEnginePage::newWindowRequested() signal. Similarly  QWebEnginePage::acceptNavigationRequest() can be implemented by handling the QWebEnginePage::navigationRequested() signal. These new request objects also provide more data than the old method call did.

​已经引入了一些方法,以避免用户必须从QWebEnginePage派生。例如,QWebEnginePage::createWindow()完成的工作现在也可以通过处理QWebEnginePage::newWindowRequested()信号来完成。类似地,QWebEnginePage::acceptNavigationRequest()可以通过处理QWebEnginePage::navigationRequested()信号来实现。这些新的请求对象也提供了比旧方法调用更多的数据。

QWebEngineDownloadItem has been renamed QWebEngineDownloadRequest to be more consistent with other API.

​QWebEngineDownloadItem已重命名为QWebEngineDownloadRequest,以便与其他API更一致。

QWebEngineLoadingInfo used to be WebEngineLoadRequest in QML, and is new API in C++. It provides more information about loading progress and errors.

​QWebEngineLoadingInfo在QML中曾经是 WebEngineLoadRequest,是C++中的新API。它提供了有关加载进度和错误的更多信息。

QWebEngineProfile, QWebEngineScript, QWebEngineScriptCollection, QWebEngineClientCertificationSelection, QWebEngineSettings and QWebEngineFullscreenRequest have all been moved from WebEngineWidgets to WebEngineCore with minimal changes.

QWebEngineProfile、QWebEngineScript、QWebEngineScriptCollection、QWebEngineClientCertificationSelection、QWebEngineSettings和QWebEngineelScreenRequest都已从WebEngineWidgets移动到WebEngineCore,改动极小。

Future API

未来的API

One of the APIs we hope to introduce is a QtGUI only replacement for QWebEngineView called QWebEngineWindow. This should also help us avoid the dependency on QQuickWidget and its limitations. It is targeted for Qt 6.4 or 6.5.

我们希望引入的API之一是QWebEngineView的纯QtGUI替代品,称为QWebEngineWindow。这也应该帮助我们避免对QQuickWidget的依赖及其局限性。它针对的是Qt 6.4或6.5。

Other work include using ANGLE inside Chromium to be able to render onto D3D or Metal. This is also what the Vulkan implementation  does internally, but Chromium only has OpenGL, Software and Vulkan compositor APIs for embedders at this point.

其他工作包括使用内部的ANGLE,以便能够渲染到D3D或Metal上。这也是Vulkan实现在内部所做的,但Chromium目前只有OpenGL、软件和Vulkan compositor API可供嵌入式程序使用。

你可能感兴趣的:(QtBlog,qt)