QtWebEngine JS Bridge
-
With Qt WebKit, we used the javaScriptWindowObjectCleared signal on the frame to do something like this:
d->frame()->addToJavaScriptWindowObject("qMapView", this);
In order to link an object in C++ to the JavaScript for simple messaging back and forth in our mapping application. I was excited to port to QtWebEngine since we're having some performance problems, to see if there would be any improvement to UI response. However, it is not clear whether or not C++ <=> JS communications are possible yet with the QWebEnginePage. I have seen some suggestion on the Trello board that QWebChannel would be used, but I can't see where this would integrate on the C++ side.
With 5.4 beta or dev version of QtWebEngine is it possible to call C++ via QWebChannel or otherwise?
-
The change to get this working in dev for 5.5 is at https://codereview.qt-project.org/93800 and isn't ready yet.
Until then I think that you can already use the WebSockets backend of QtWebChannel.
If not possible you can also pass raw messages through QWebEnginePage::runJavaScript using QJsonDocument.
-
Cool, I will play with that. The use case is pretty straightforward, just sending objects back and forth from a web container showing a map view with some overlays, markers, and infoboxes. The core data models and dynamic image generation are on the C++ side. If we come up with anything interesting we would be happy to release in generalized form for others' benefit
Cheers,
Patrick -
@Patrick: I have the same problem and it's still not clear how to port it to webengine. did you play with it and learned something ? if yes, could you please share.
Thanks
Marco -
@Patrick: I have the same problem and it's still not clear how to port it to webengine. did you play with it and learned something ? if yes, could you please share.
Thanks
Marco