Qt For WebAssembly
Written by Ian Elliot   
Wednesday, 25 April 2018

Qt is a popular way to construct a cross platform UI, but the latest move is into the unknown and could change the way we create web apps. Qt for WebAssembly is now in beta.


Qt is a widget library and generally a way to build a UI on a range of different platforms including Windows, Linux and macOS with lots of other less well supported options. It is written in C++, which is something many users don't like, but there are bindings to other languages including Python, Rust, Go, Java and JavaScript. 

There are a few things wrong with Qt - its documentation, for example, is fine as long as you are within the main areas of use, but as soon as you try to find out about one of the many side applications things fall apart. It suddenly becomes very difficult to find out, say, how to use Qt with JavaScript.

The main problem with Qt is that many potential users are confused about the licencing issues. The Qt company offers an open source version and a commercial licenced version. Obviously it wants you to pay up and keep the company going, but many programmers don't understand the terms of the open source licence. The most common interpretation is that you have to open source your own proprietary code and this is a big negative. Worse, some even think that this means you can't sell an open source Qt project. The truth is fairly well hidden in the documentation. The main gist is that you can keep your code proprietary and sell it as long as the user is free to substitute a new Qt library, i.e. you have to use dynamic linking and you can't modify the Qt library. If you do modify the Qt library then you have to make the changes open source.

"It is recommended to either link dynamically, or provide the application source code to the user under LGPL."

There are various other restrictions, but none that should impact the average project, commercial or open source. If you are working with a big company with lots of patents to enforce, then you are better with the commercial edition because of the patent clause in the LGPL.

OK, with this all explained what has Qt got to do with WebAssembly?   



WebAssembly is a low level language that is loaded and run under the control of a JavaScript program. The idea is that you write an app in another language and compile it to WebAssembly. Once loaded into a page it runs more like a native app than a JavaScript app. The only problem is that you have to work out how to create a GUI. One way is to write special code that interfaces your program with the DOM. The Qt way is to use Qt to write a program that just runs as it would in any other Qt environment. The attraction is obvious as yet another "write once run everywhere" attempt.

How does this work?

The answer is that it uses a canvas element to draw the UI and hence there is minimal interaction with the DOM. You can work within your Qt program without worrying about HTML and can let the framework render the UI elements.

Currently there is a beta that you can try out and there should be a tech preview included with Qt 5.11. At the moment you can only try it out on Linux or macOS, i.e. not Windows. You also have to install and use Emscripten, the C/C++ compiler to WebAssembly, and this isn't trivial. Some users are reporting successfully running large Qt apps in the browser. There are a few demos, but nothing that would excite an innocent user.

Of course there are the doubters who think that the whole WebAssembly issue is just another complication in an already over-complex environment and adding Qt to the mix is even worse.

Perhaps in the future we will be using any language we care to with Qt for the UI and have apps running in the browser or native, but not quite yet.


More Information

Beta for Qt for WebAssembly Technology Preview


Related Articles

WebAssembly Explorer - A Learning Tool

WebAssembly Is Ready For Use

WebAssemby Another Milestone 

WebAssembly Takes A Big Step Towards Being Real 

Progress On WebAssembly 

WebAssembly Has Mozilla, Microsoft,Apple and Google Backing It 

QT 5.7 Released

Qt 5.6 Released

Qt 5.5 Released

Qt 5.4 Released

Qt’s New Home

Qt 5.3 Released

Qt 5.2 Released

Digia Buys Qt Development Platform

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.



Important Conference Results

The SIGBOVIK conference has just finished and its proceedings can be downloaded, but only at your peril. You might never see computer science in the same way ever again.

Deno Improves JSR Support

Deno has been updated to improve JSR support, and to build on the Temporal API introduced in version 1.4.  Deno is the JavaScript and TypeScript runtime from the creator of Node.js.

More News

raspberry pi books



or email your comment to: comments@i-programmer.info

Last Updated ( Wednesday, 25 April 2018 )