Important: Please read the Qt Code of Conduct -


  • Some of the libraries like OpenSSL and CURL should not run on the main thread, otherwise they will block the application. I could solve this problem on a non-Qt application by using PROXY_TO_PTHREAD for building, which worked without any problem. However, when I add this flag to the Qt based app I start getting errors in this line:

    emscripten::val::global("window").set("onbeforeunload", val::module_property("qtBrowserBeforeUnload"));

    In the file qwasmintegration.cpp. It looks like when we proxify the main function emscripten::val::global("window") returns null.
    The solution I had was making CURL requests on another thread. But then, I could not update the models from that thread getting the error:
    Uncaught TypeError: Browser.mainLoop.scheduler is not a function

    So the final solution was updating the model on the main thread using a timer, which is far from being ideal.

    How can I get Qt to work with PROXY_TO_PTHREAD?

  • Lifetime Qt Champion

    @Ahmed-Yarub-Hani-Al-Nuaimi said in PROXY_TO_PTHREAD Support:

    But then, I could not update the models from that thread getting the error

    You can emit signal from that thread and update the models in main thread in a slot connected to this signal.

  • @jsulm thank you for the answer. That might work indeed, but the thing is the same application works on Windows, iOS, Mac, Android, and Linux. I'd have to change the logic just to make it work with Wasm. I could easily run non-Qt application simply by proxifying the call to main, is there a way to get that to work with Qt5 apps?

Log in to reply