靜態構建不被支持。
The requirements for building Qt modules from source are listed separately for each supported platform:
此外,需要以下工具為構建 Qt WebEngine 模塊:
注意: Qt WebEngine requires a C++20-compatible compiler on all platforms, due to its dependency on the Chromium project. While Qt as a whole only requires C++17, Qt WebEngine is an exception.
On all platforms, the following tools are required at build time:
在 Windows,需要以下額外工具:
注意:
It is not recommended to use tools from
msys2
or
cygwin
to build Qt WebEngine as it may result in build errors.
注意: Currently, Qt WebEngine does not compile with MinGW.
On Linux, the following additional tools are required:
Qt WebEngine 要求
pkg-config
以檢測其大多數依賴。以下
pkg-config
文件要求:
若 Qt 被配置為
xcb
,以下
pkg-config
文件也是必需的:
在 macOS,需要以下:
注意:
無法為 macOS 的 32 位模式構建 Qt WebEngine (使用
macx-clang-32
mkspec
).
Building Qt WebEngine with earlier Qt versions (down to the last LTS version) is supported. It means that Qt WebEngine 6.4 can be built with Qt 6.2.x, Qt 6.3.x, and Qt 6.4.
要使用早期 Qt 版本構建 Qt Webengine:
../qtbase/bin/qt-configure-module . cmake --build . --parallel cmake --install .
注意:
You may also use
qmake
with
make
and
make
install, but this method is considered legacy and not recommended for Qt 6 and later.
Applications using Qt WebEngine are not compatible with the Mac App Store, because:
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.
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 為 Chromium 渲染過程提供開箱即用的沙盒支持。
在 Linux,注意以下限定:
/proc/sys/kernel/unprivileged_userns_clone
到 1。
seccomp-bpf
特徵 (內核版本 3.5 或更高版本)。
要明確禁用沙盒,使用以下選項之一:
QTWEBENGINE_DISABLE_SANDBOX
環境變量到 1。
--no-sandbox
命令行自變量,給用戶應用程序可執行文件。
QTWEBENGINE_CHROMIUM_FLAGS
to
--no-sandbox
.
更多信息,見 使用命令行參數 .
當在 Docker 容器中運行 Qt WebEngine 範例並瀏覽內容繁重站點時,可能報告 BUS 錯誤 (SIGBUS)。通常,這是由於 Docker 運行過小內存空間 (譬如 64MB) 容器導緻的。要修復此問題,增加內存空間大小。
Qt WebEngine enables accessibility support for web pages when the following conditions are met:
On some old Linux configurations, accessibility can cause a significant slowdown on large HTML pages.
Because of that, Qt WebEngine accessibility support can be disabled on Linux, by setting the
QTWEBENGINE_ENABLE_LINUX_ACCESSIBILITY
environment variable to 0.
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 is described in 基於 OpenGL 的窗口全屏 .
A manifest is an XML file that is read when the program starts and informs Windows how to run the program. Some Qt WebEngine features may require adding a manifest file for the user application to work correctly on Windows.
The following snippets show the manifest file's structure and how to embed it into the program.
注意: These code snippets are taken from the WebEngine Quick 納米瀏覽器 範例。
The manifest file defines which Windows versions the application supports. httpUserAgent needs this information to report the correct Windows version.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--The ID below indicates application support for Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!--The ID below indicates application support for Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!--The ID below indicates application support for Windows 10/11 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
</assembly>
To embed the file into the executable, add it to the sources:
...
qt_add_executable(quicknanobrowser
main.cpp
)
if(WIN32)
set_property(
TARGET quicknanobrowser
APPEND PROPERTY
SOURCES quicknanobrowser.exe.manifest)
endif()
...