Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. Passing emscripten::val in signal/slot
Forum Updated to NodeBB v4.3 + New Features

Passing emscripten::val in signal/slot

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
1 Posts 1 Posters 306 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    ToreB
    wrote on last edited by ToreB
    #1

    Modified the QThread documentation example so that the Worker::resultReady() signal passes a value of type emscripten::val instead of QString:

    qRegisterMetaType<emscripten::val>();
    connect(worker, &Worker::resultReady, this, &Controller::handleResults);
    
    void Worker::doWork(const QString &parameter)
    {
        qInfo() << "Worker::doWork()" << QThread::currentThread();
        emit resultReady(emscripten::val((parameter + "bar").toStdString()));
    }
    
    void Controller::handleResults(const emscripten::val &result)
    {
        qInfo() << "Result of operation:" << QString::fromStdString(result.as<std::string>()) << QThread::currentThread();
    }
    

    Running in Chrome, with sharedArrayBuffer enabled, this fails:
    35b24db9-7868-4de3-8bda-c6e1f5d7b61a-image.png

    Is there a way I can have a QThread web worker create a new JavaScript object and pass it on to the main thread ?

    Qt 6.4 (-feature-thread) - emscripten 3.1.16

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved