Science and technology

Create net consumer interfaces with Qt WebMeeting as an alternative of JavaScript

When I first heard about WebAssembly and the potential of creating net consumer interfaces with Qt, identical to I might in extraordinary C++, I made a decision to take a deeper have a look at the know-how.

My open supply mission Pythonic is totally Python-based (PyQt), and I take advantage of C++ at work; subsequently, this minimal, easy WebMeeting tutorial makes use of Python on the backend and C++ Qt WebMeeting for the frontend. It is aimed toward programmers who, like me, aren’t aware of net improvement.


git clone

cd wasm_qt_example


Then go to along with your favourite browser.

What is WebMeeting?

WebMeeting (typically shortened to Wasm) is designed primarily to execute transportable binary code in net functions to attain high-execution efficiency. It is meant to coexist with JavaScript, and each frameworks are executed in the identical sandbox. Recent performance benchmarks confirmed that WebMeeting executes roughly 10–40% sooner,  relying on the browser, and given its novelty, we are able to nonetheless anticipate enhancements. The draw back of this nice execution efficiency is its widespread adoption as the popular malware language. Crypto miners particularly profit from its efficiency and more durable detection of proof attributable to its binary format.

There is a getting started guide on the Qt wiki. I like to recommend sticking precisely to the steps and variations talked about on this information. You may have to pick out your Qt model fastidiously, as completely different variations have completely different options (equivalent to multi-threading), with enhancements occurring with every launch.

To get executable WebMeeting code, merely cross your Qt C++ utility by means of Emscripten. Emscripten supplies the whole toolchain, and the construct script could not be easier:

supply ~/emsdk/

Building takes roughly 10 occasions longer than with an ordinary C++ compiler like Clang or g++. The construct script will output the next recordsdata:

  • WASM_Client.js
  • WASM_Client.wasm
  • qtlogo.svg
  • qtloader.js
  • WASM_Client.html
  • Makefile (intermediate)

The variations on my (Fedora 30) construct system are:

  • emsdk: 1.38.27
  • Qt: 5.13.1


The frontend supplies some functionalities primarily based on WebSocket.

  • Send message to server: Send a easy string message to the server with a WebSocket. You may have achieved this additionally with a easy HTTP POST request.
  • Start/cease timer: Create a WebSocket and begin a timer on the server to ship messages to the consumer at an everyday interval.
  • Upload file: Upload a file to the server, the place the file is saved to the house listing (~/) of the consumer who runs the server.

If you adapt the code and face a compiling error like this:

error: static_assert failed attributable to
 requirement ‘bool(-1 == 1)’ “Required characteristic http for file
 ../../Qt/5.13.1/wasm_32/embrace/QtCommunity/qhttpmultipart.h not out there.”

it implies that the requested characteristic is just not out there for Qt Wasm.


The server work is completed by Eventlet. I selected Eventlet as a result of it’s light-weight and simple to make use of. Eventlet supplies WebSocket performance and helps threading.

Inside the repository underneath mysite/template, there’s a symbolic hyperlink to WASM_Client.html within the root path. The static content material underneath mysite/static can be linked to the foundation path of the repository. If you adapt the code and do a recompile, you simply need to restart Eventlet to replace the content material to the consumer.

Eventlet makes use of the Web Server Gateway Interface for Python (WSGI). The features that present the particular performance are prolonged with decorators.

Please notice that that is an absolute minimal server implementation. It would not implement any multi-user capabilities — each consumer is ready to begin/cease the timer, even for different shoppers.


Take this instance code as a place to begin to get aware of WebMeeting with out losing time on minor points. I do not make any claims for completeness nor best-practice integration. I walked by means of a protracted studying curve till I received it working to my satisfaction, and I hope this offers you a short look into this promising know-how.

Most Popular features the latest multimedia technologies, from live video streaming to audio packages to searchable archives of news features and background information. The site is updated continuously throughout the day.

Copyright © 2017 Breaking Express, Green Media Corporation

To Top