Critical information for every developer.
In typical, native, Qt setting, modal windows allocated on stack and block upon opening. To manage the modal window, Qt spins up a second event loop. However, that is not technically possible in Web-Assembly environment. (This might be solved in new Qt with “asyncify” build flag, but it does not work with currently used Qt 5.15.2)
QMessageBox msg;
msg.exec();
QMessageBox::critical("Hello");
The .exec()
method and single line call are typical warning signs.
Some parts of code employ special code for Web-Assembly (like HTML file selector) and the native part may use blocking solution. However, in performance non-critical parts (which most dialogs are), unified asynchronous solution is preferred.
The modal window object has to be allocated dynamically and started using asynchronous method open
. Answer has to be
obtained via connect
callback.
For ease of use, wrapper functions are prepared in gui/helper/async_modal.h
.
Free can be accomplished using special call msg->setAttribute(Qt::WA_DeleteOnClose)
before opening. This method is
automatically employed in async_modal.h
.
Docs: WA_DeleteOnClose , QCloseEvent