WebAssembly 是允许在网页沙盒执行代码的二进制格式。这种格式几乎和本机代码一样快,且现在所有主流 Web 浏览器都支持。
Qt for WebAssembly enables building Qt applications so that they can be integrated into web pages. It doesn't require any client-side installations and reduces the use of server-side resources.
The experimental WebAssembly plugin enables you to build your applications in WebAssembly format and deploy and run them in the local web browser. You can change the web browser in the project run settings.
To build applications for the web and run them in a web browser, you need to install Qt for WebAssembly and the tool chain for compiling to WebAssembly.
You need the following software to build Qt applications for the web and run them in a browser:
sed
stream editor
注意:
You need to add the location of the MinGW and
sed
installation folders to the system path, either globally or for the Qt for WebAssembly kit.
You need to install and configure Qt for WebAssembly and the tool chain for compiling to WebAssembly. The Qt Installer automatically adds a build and run kit to Qt Creator.
To set up Qt for WebAssembly:
emsdk
and install and activate
emscripten
, as instructed in
Qt for WebAssembly
.
注意:
不使用
--embedded
option for activating the
emscripten
version in the
emsdk
, because Qt Creator expects to find the
.emscripten
file describing the toolchain in your home directory.
sed
, as instructed in
sed for Windows
.
To enable the plugin:
To configure Qt Creator for building Qt apps for the web:
.emscripten
文件。
sed
to the PATH variable. For example, on Windows:
PATH=C:\Qt\Tools\mingw730_64\bin;C:\Program Files (x86)\GnuWin32\bin;${PATH}
The Qt for Web Assembly installation automatically adds build and run kits to Qt Creator. To add kits:
sed
to the PATH variable.
To run a project:
You can now build Qt applications in WebAssembly format and run them in a web browser as described in 为多个平台进行构建 and 在多个平台上运行 .