DEV Community

Cover image for Qt for WebAssembly
Ben Lovy
Ben Lovy

Posted on

Qt for WebAssembly

As of Qt 5.13, WebAssembly is a supported target.

Qt is a cross-platform toolkit for building GUI applications. It is the toolkit used in the KDE set of Linux desktop tools, as well as the basis for widely used commercial and FOSS applications such as Photoshop Elements, Mathematica, VLC, and VirtualBox - and many more.

This release means you can distribute Qt apps as if they were web applications, and users execute them install-free entirely within in a web browser (or other WASM environment), at near-native performance - almost as if it had been installed locally.

Has anyone tried this out yet? How did it go? Will any of you be eschewing React Native or Flutter for this, or porting a desktop application? Why or why not?

cover image: kde mascots

Top comments (11)

Collapse
 
trusktr profile image
Joe Pea

I think Qt will result in heavy WebAssembly modules, especially if you need a simple UI.

I'm looking forward to using AssemblyScript with github.com/infamous/glas For WebGL-based rendering, and reference types (github.com/WebAssembly/reference-t...) which will allow direct manipulation of the DOM (or any JS objects) from inside a WebAssembly module.

AssemblyScript is a strict subset of TypeScript that compiles to WebAssembly (and by extension, to other native assembly formats). assemblyscript.org/

Of course, if you have many tools already written in Qt (UI components or something) that you'd like to re-use, then now you can use them for web too, to some extent (not everything in Qt can be ported to WebAssembly). :)

Collapse
 
deciduously profile image
Ben Lovy

I think Qt will result in heavy WebAssembly modules, especially if you need a simple UI.

I definitely made a mistake in comparing this tool to React Native and Flutter. It's not for the same sort of thing at all, and I agree that AssemblyScript is much more interesting there. I do think, though, that this will enable people to leverage WASM for much more complex concerns where bundle size is not a primary concern but the flexibility of a complicated desktop application, like photo manipulation software, to be created in a way that wasn't previously feasible.

Collapse
 
trusktr profile image
Joe Pea

Plus, eventually, once WebAssembly Interface Types are out and Wasm gains the ability to work directly with DOM references, this will make it possible to write web applications in Qt using C++ (for example, suppose they integrate something like gccx into the toolchain, which would allow developers to write functional components with HTML-like syntax embedded inside the functions).

Collapse
 
trusktr profile image
Joe Pea

Coincidentally I just stumbled on this article on writing web interfaces with Qt + WebAssembly: opensource.com/article/20/2/wasm-p...

Thread Thread
 
chilarai profile image
Chilarai

At this point, Qt WebAssembly lacks a lot of modules that are available in other Qt desktop and mobile projects. Its at a nascent stage and still has a lot to go before being adopted by the mass

Collapse
 
soheilarmin profile image
Soheil Armin • Edited

I'm currently building a product on top of it. It's amazing. The output .wasm is heavy but it's acceptable for some use-cases. Official demos of Qt for Wasm are awful. So, I'm creating a split-flap flight table using QML. I hope that I will have time to put it on Github soon.

Collapse
 
deciduously profile image
Ben Lovy

Definitely interested to see if you do get the time!

Collapse
 
aghost7 profile image
Jonathan Boudreau

Funny you mention this, because druid also supports a web backend. I'll probably write an app sometime next year in Rust.

Collapse
 
deciduously profile image
Ben Lovy

I've been looking at this too! A side by side comparison might be interesting.

Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Very interesting!

Collapse
 
deciduously profile image
Ben Lovy

Seems like there's a decent amount of interest, but not a ton of hands-on experience with this particular tool yet. I'm setting myself a note to ask again in a year...