Qt WebEngine 平台注意事项

从源代码构建 Qt WebEngine

静态构建不被支持。

分别列出从源代码构建 Qt 5 模块的要求,对于各个支持平台:

此外,需要以下工具为构建 Qt WebEngine 模块:

跳过 Qt WebEngine 构建的测试位于 qtwebengine 存储库,在 tools\qmake\mkspecs 子目录。可以找到它们通过搜索 skipBuild .

所有平台

所有平台都需要下列工具:

  • Python 2.7.5 或更高版本。不支持 Python 3。
  • Bison, Flex
  • GPerf

Windows

On Windows, Visual Studio 2015 or 2017 and Windows 10 SDK are required.

Linux

On Linux, Clang or GCC version 4.7 or later is required. Supported configurations are linux-g++ and linux-clang .

Qt WebEngine 要求 pkg-config 以检测其大多数依赖。以下 pkg-config 文件要求:

  • dbus-1
  • fontconfig

若 Qt 被配置为 xcb ,以下 pkg-config 文件也是必需的:

  • libdrm
  • xcomposite
  • xcursor
  • xi
  • xrandr
  • xscrnsaver
  • xtst

进一步,开发包为 khr and libcap 需要安装。

macOS

On macOS ,需要下列:

注意: Qt WebEngine cannot be built for the 32-bit mode of macOS (using the macx-clang-32 mkspec ).

Mac APP 商店兼容性

Applications using Qt WebEngine are not compatible with the Mac App Store, because:

  • The Chromium part of the code uses several private API methods, which are prohibited by the App Store.
  • Applications submitted to the App Store must be code-signed with the App Sandbox feature enabled. The App Sandbox feature interferes with Chromium's own sandbox initialization, which results in Chromium not being properly initialized. This also ties in with the private API usage. Furthermore, standalone Chromium itself is not officially tested with the App Sandbox enabled, and even if work is done to bypass the App Store's restrictions, that would not guarantee correct behavior of the library.

支持带双 GPU 的 MacBook macOS Airplay

To make Qt WebEngine work correctly when streaming to an AppleTV from a MacBook that supports GPU switching, it is important to add the NSSupportsAutomaticGraphicsSwitching option to the application Info.plist file, with the value set to YES . Otherwise rendering issues might occur when creating new web engine view instances after Airplay is switched on or off.

默认支持 QSurfaceFormat OpenGL Profile (配置文件)

If a new default QSurfaceFormat with a modified OpenGL profile has to be set, it should be set before the application instance is declared, to make sure that all created OpenGL contexts use the same OpenGL profile.

On macOS , if the default QSurfaceFormat is set after the application instance, the application will exit with qFatal (), and print a message that the default QSurfaceFormat should be set before the application instance.

沙盒支持

Qt WebEngine provides out-of-the-box sandboxing support for Chromium render processes on Linux and macOS . Sandboxing is currently not supported on Windows due to a limitation in how the sandbox is set up and how it interacts with the host process provided by the Qt WebEngine libraries.

On macOS , there are no special requirements for enabling sandbox support.

On Linux, the kernel has to support the anonymous namespaces feature (kernel version >= 3.8) and seccomp-bpf feature (kernel version >= 3.5). Setuid sandboxes are not supported and are thus disabled.

To explicitly disable sandboxing, the QTWEBENGINE_DISABLE_SANDBOX environment variable can be set to 1 or alternatively the --no-sandbox command line argument can be passed to the user application executable.

可访问性和性能

Qt WebEngine enables accessibility support for web pages when the following conditions are met:

  • Qt Core is configured and built with accessibility support enabled.
  • The QPA plugin is notified by the operating system that accessibility should be activated. This happens for example when using a screen reader application on Windows or VoiceOver on macOS .

Due to some limitations, the Linux QPA plugin almost always reports that accessibility should be activated. On big HTML pages, this can cause a significant slowdown in rendering speed.

Because of that, from Qt 5.9 onwards, Qt WebEngine accessibility support is disabled by default on Linux. It can be re-enabled by setting the QTWEBENGINE_ENABLE_LINUX_ACCESSIBILITY environment variable to a non-empty value.

Windows 全屏应用程序中的弹出窗口

Because of a limitation in the Windows compositor, applications that show a fullscreen web engine view will not properly display popups or other top-level windows. The reason and workaround for the issue can be found at 基于 OpenGL 的窗口全屏 and QWindowsWindowFunctions::setHasBorderInFullScreen .