Porting desktop app to WebAssembly: Good pattern to replace QDialog::exec() calls?
-
In simple cases it's easy to replace QDialog::exec() with the asynchronous QDialog::open() and moving all the code to run after the dialog is closed to a lambda/function executed when that dialog emits QDialog::finished with the return code QDialog::Accepted.
When porting a larger application with more complex logic, I cannot find a good, "works-in-all-cases" replacement for QDialog::exec(). Sometimes a dialog has to return a value BEFORE the function creating it returns, and there is no way to stop that function until it does... Simply put, I need a modal, synchronous QDialog::open(). If necessary, the background can remain frozen, until the dialog is closed.
I have to port many calls like this:
while (someQDialog.exec());
which repeatedly opens a dialog where a new item can be defined, until the user cancels it. How could I make this work with WebAssembly?
I have compiled Qt for WebAssembly with multithreading support.
-
exec() on wasm does not work like any other system, it will never return, because nested event loops are not supported in Emscripten/webassembly.
You would need to use signals and slots and show() to get any return values from any dialog.
-
@lorn-potter
Hi there. I know Qt WebAssembly is a work-in-progress. Is there a current (preferably "definitive") list anywhere of what does not work from Qt which we can read/refer other questioners to? Otherwise we seem to wait for you to pop in here! :)