20 Dec 2025

Qt app in your browser

Emscripten is a tool that allows you to compile a C++ program so that it can run directly inside your web browser.

I created a small example demonstrating this, which is hosted on GitHub.

One limitation I encountered was that the message box I wanted to display would cause the application to crash when using the following API:

1
QMessageBox::information(...);

To make it work correctly, I had to use the open() function and construct the message box manually over several lines. Unlike the static convenience functions, open() does not block the caller, allowing Emscripten to continue execution without issues.

1
2
3
4
5
6
QMessageBox *msgBox = new QMessageBox(this);
msgBox->setWindowTitle(...);
msgBox->setText(...);
msgBox->setIcon(QMessageBox::Information);
msgBox->setAttribute(Qt::WA_DeleteOnClose);
msgBox->open();  // Non-blocking
Thank You For Reading
Laurent Carlier

Do not hesitate to contact me via e-mail ([email protected]) if you have any question or comment. If see an error, you can issue a pullme request om my github