Passing emscripten::val in signal/slot
-
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 ¶meter) { 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:
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