WebAssembly (or webasm) is a bytecode format intended to be executed in a virtual machine inside a web browser. This allows an application to be deployed to a device with a compliant web browser without going through any installation steps. The application will run inside a secure sandbox in the web browser. This makes it appropriate for applications that do not need full access to the device capabilities, but benefits from a swift and uncomplicated installation process.
If the browser supports WebAssembly, then Qt should run.
Note: Qt has a fixed WebGL requirement, also for apps that do not use WebGL directly. Browsers often blacklist WebGL for older/unsupported GPUs.
Note: There is currently no support for text input using the virtual keyboard. Safari currently does not support wasm modules of the size Qt produces.
Qt does not make direct use of operating system features and it makes no difference if, for example, FireFox runs on Windows or macOS. Qt does use some operating system adaptations, for example for ctrl/cmd key handling on macOS.
Qt for WebAssembly supports a subset of the Qt modules. The list below lists the currently tested modules. The list can be pasted as arguments to make
.
module-qtbase module-qtdeclarative module-qtquickcontrols2 module-qtwebsockets module-qtsvg module-qtcharts module-qtmqtt
Other modules are untested and may work. Are not supported: QtMultimedia and QtWebView
Refer to the wiki.
QWebSocket socket;
QUrl url{QString("ws://server:port")};
QNetworkRequest request{url};
request.setRawHeader("Sec-WebSocket-Protocol", "binary");
socket.open(request);
Example | gzip | brotli |
---|---|---|
helloglwindow (QtCore + QtGui) | 2.8M | 2.1M |
wiggly widget (QtCore + QtGui + QtWidgets) | 4.3M | 3.2M |
SensorTag (QtCore + QtGui + QtWidgets + QtQuick + QtCharts) | 8.6M | 6.3M |
Compression is typically handled on the web server side, using standard compression features: the server compresses automatically or picks up pre-compressed versions of the files. There's generally no need to have special handling of wasm files.
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.15/qtwebassembly-platform-notes.html