Porting a Qt Project to WebAssembly: Challenges and Solutions

In this post, I describe porting a small application, a calculator called SpeedCrunch, to WebAssembly and some common issues that need to be addressed. I hope you may find some solutions helpful and save time should you want to target the WebAssembly platform with your code.

For those eager to see the result, the application is available here: SpeedCrunch (WebAssembly)

I have also compiled and bundled a new Windows version (with all my changes included): /files/speedcrunch/speedcrunch-0.12.1.zip

Introduction

Porting a Qt application to WebAssembly (WASM) presented some unique challenges. Qt, known for its cross-platform capabilities, initially posed difficulties when targeting WebAssembly, but improved support in later versions smoothed the process. Announced in 2015 and first released in March 2017, WebAssembly was added as an officially supported target to Qt with Qt 5.13.

The application I wanted to port is a small but highly practical calculator called SpeedCrunch. The desktop version was my trusted companion for more than a decade, particularly for work involving binary number manipulation, thanks to its efficient binary digits editor. This feature was invaluable for working with binary representations, a common task in my professional workflow as a CPU architect. Beyond work, I also used the application for various personal calculations.

Click to enlarge the image.

Continue reading

A Calculator (4): The Framework

For as long as I remember, I had played with LEGOs. Those simple blocks would transform into complex objects whose final shapes only existed in the supple thoughts of creative imagination. The kind of LEGO blocks we had while growing up were simple: 2×4, 2×2, 1×8. Anything unusual was rare and precious.

Continue reading

A Calculator (3): Practical Numerical Methods

In the last post, we verified and quantified the precision of the basic four functions (addition, subtraction, multiplication, and division). Now, we can use them as a stepping stone for more complex functions. We can assume they will be available, so our experimentation could simply use built-in C++ functions.

In this article, the third in a series, we will continue with the proof-of-concept, or pathfinding, research.

Continue reading

A Calculator

The idea for this project came about during a week of freezing winter arctic events here in Austin, Texas, with a failed power grid (as well as the Texas government), while keeping close to a gas fireplace, the only source of heat and light, for a couple of days. With a weak internet over a phone data line, I could only do some preliminary searches and mainly work out various details on a writing pad, growing feeling that the project may be personally exciting and practically doable.

It took a long time, but this FPGA Calculator is now finished and I am really happy with how well it turned out.

Continue reading