Skip to content

Qt for WebAssembly

Specific issues when using Qt for WebAssembly

440 Topics 1.7k Posts
  • Help Developing New Tool (Open Source)

    Locked Unsolved
    2
    1 Votes
    2 Posts
    271 Views
    SGaistS

    Hi,

    Please do not the same thread on multiple sub-forum. One is enough

    Duplicate

    Closing this one.

  • 0 Votes
    3 Posts
    989 Views
    ConfusedKeystrokesC

    @lorn-potter Thanks for getting back to me!

    I'm trying to build this project:
    https://github.com/herewegoblueno/cs1230-final
    Just to provide context, this works well when built for Mac.

    And yes I am importing GL/glew.h myself.

    Also by the way I've also noticed that the compilers don't recognize the standard libraries like <vector>, <map>, etc (or maybe that's just the static checker? not sure if those will result in compile time errors since I can't build due to glew anyways)

  • 0 Votes
    3 Posts
    561 Views
    R

    Hi,

    What I'm doing on Android is the following:

    I build a qml ui and some corresponding c++ and inline js code that make sure that the qml ui can communicate with the android java layer through the android webview utilizing webchannel messageing. See: https://github.com/r0ller/qwa/tree/main/qmlwasm1
    Files:
    main.qml (just the ui logic)
    main.cpp (opening webchannel port)
    messageboard.cpp (sending/receiving messages through webchannel port)

    The java layer passes the call to a c/c++ backend lib via JNI and the returned response is sent back to qml via webmessage channel. The corresponding code:
    https://github.com/r0ller/qwa/blob/main/Android/qmlwasm1/app/src/main/java/com/bitroller/qmlwasm1/MainActivity.java

    All that works fine, the error does not appear in the Android but only in the nodejs use case when reloading the client from the nodejs server. However, the ui part what gets loaded from the server is the same what I load in the webview on Android. I also don't get any errors when the project is built with the same qml ui as native.

    By the way, you can find both the apk and the nodejs code in the repo so running the nodejs variant is just issuing "node index.js" in the qwa_node directory after cloning ;) Installing the apk of course is a few clicks and taps more.

    (Yesterday I added a springanimated rect to the qml ui which I did not copy over to the android project so there's a difference but that's not the point here.)

    BR,
    r0ller

  • TextInput not editable in browser

    Unsolved
    2
    0 Votes
    2 Posts
    510 Views
    SyntaXS

    I noticed, that although I am not able to "write" Text in the input field, I can paste text from elsewhere?

  • Qt Webassembly number of screens

    Unsolved
    1
    0 Votes
    1 Posts
    394 Views
    No one has replied
  • 0 Votes
    3 Posts
    2k Views
    lorn.potterL

    BINARYEN_TRAP_MODE=clamp has been part of Qt WebAssembly since before is was integrated into Qt proper.
    Look at: mkspecs/wasm-emscripten/qmake.conf

    It is not needed for WASM_OBJECT_FILES, which is now the default, so it was removed in the 5.15 series.

    There was a typo (a missing + in +=) for a while that stopped it from actually being used

  • How to use gzip in WASM qt?

    Unsolved
    1
    0 Votes
    1 Posts
    395 Views
    No one has replied
  • How to do callbacks/slots in Qt for WebAssembly?

    Solved
    7
    0 Votes
    7 Posts
    1k Views
    lorn.potterL

    @Edwin-F WebSockets are two way communication, but only a client process can run on WebAssembly/browser.
    https://doc.qt.io/qt-5/qtwebsockets-index.html

  • Qt webassembly and Layouts

    Solved
    5
    0 Votes
    5 Posts
    854 Views
    A

    Found the problem: I had installed Qt v 6.0.0 with emscripten 1.39.8. documents say 1.39.8 should work with Qt v5.15.0. Works after installing the correct Qt version.

  • Qt Webassembly with WASI (lucet, wasmtime)?

    Solved
    3
    0 Votes
    3 Posts
    527 Views
    A

    Thank you.

  • 0 Votes
    2 Posts
    571 Views
    M

    Problem solved by removing the emrun flag. I can now specify custom arguments in the qtloader.js using emscripten's Module.arguments like this :

    Module['arguments'] = ['FirstArg', 'SecondArg'];
  • WebAssembly and remote objects module

    Solved
    2
    0 Votes
    2 Posts
    347 Views
    lorn.potterL

    WebAssembly as a platform, does not have native support for servers (same as javascript). Emscripten does support using servers via proxy, but that requires a real server.
    As well, Qt WebAssembly does not yet support emscripten tcp proxy as it requires to run main() in a webworker and pass graphical data to the main thread for canvas access.

  • No rule to make target .... libqtmain.a

    Unsolved
    4
    1 Votes
    4 Posts
    784 Views
    Y

    Are you using Qt Creator?

    Try changing the emcc compiler config's abi to asmjs-unknown-unknown-emscripten-32bit.

    @fhryilmaz @winsvu @GaryT

  • Save and access cookies from WebAssembly

    Unsolved
    2
    0 Votes
    2 Posts
    782 Views
    lorn.potterL

    You could use cookies from the javascript side:

    https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html

  • 0 Votes
    2 Posts
    406 Views
    G

    The problem was related to having a previous version installed. The .emscripten file was not updated during the install of emscripten 1.39.8 to reflect the new version. Once I correct it, QT Creator detected the installed version (1.39.8) . I was able to build and run a simple program. However, QT Creator still generate a couple of warnings.

  • 3d in WebAssembly

    Solved
    2
    0 Votes
    2 Posts
    605 Views
    lorn.potterL

    WebGL is based on opengl es2, WebGL 2 is based on opengl es3. Emsripten (and therefor Qt WebAssembly) has support for both.
    Thread support in wasm is still experimental, there are limitations.

  • 0 Votes
    3 Posts
    705 Views
    JonBJ

    @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! :)

  • Is there any working installer / setup for Windows?

    Unsolved
    6
    0 Votes
    6 Posts
    678 Views
    lorn.potterL

    on Windows, Emscripten uses MinGW as the backend. Emscripten is just python scripts that call system compilers. It uses clang to output wasm binaries.
    Qt 5.15.x requires Emscripten 1.39.8

    To get Qt Creator to use emscripten for wasm, you need the correct version of Emscripten installed and then enable the experimental wasm plugin.

  • pthread send an error (qtloader.js)

    Unsolved
    3
    0 Votes
    3 Posts
    487 Views
    B

    @jsulm I get an exception message when the exec() method (QDrag) is called (toolmaster.h: mousePressEvent). I thought it wad due to the missing multithreading support.

    This is the error message when I compile it with the default 5.15.1 binaries (console output in Firefox):

    Uncaught Please compile your program with async support in order to use asynchronous operations like emscripten_sleep
  • Python Backend/QML Frontend Can I Convert To WebAssembly?

    Unsolved
    5
    0 Votes
    5 Posts
    2k Views
    Edwin F.E

    Thanks guys @SGaist and @lorn-potter

    It seems like it is not really supported at this time and I will have to look into the alternative of putting a layer between the QML and Python backend in C++, essentially becomes a C++ app, but I only want to use C++ as a pass through to the Python somehow using PyBind11...I will try to see if that will work.