WebKitBridge, how to have Qt draw onto an existing HTML5 canvas element?
-
I have an existing "HTML5" web functionality which currently has JavaScript code to render an image from disc onto a canvas.
I'm experimenting with the QtWebKitBridge..
My Qt main window has a QWebView and I use "addToJavaScriptWindowObject" to install a pointer to the main Qt window within the DOM of the QWebView. I know how to access JavaScript from Qt, and how to access Qt INVOKABLE methods from JavaScript.
So my JavaScript functions in the embedded QWebView have a pre-existing HTML5 <canvas> element. The JavaScript side does some rendering onto the 2d context of the existing canvas. I'd like for the JavaScript side to be able to pass the "context" into the Qt side, whereby the Qt side can then do some more drawing directly onto the context.
How do I accomplish this?
edit: I think I can get this done in a round-about way by having Qt encode its output as Base64, and then write that into an image element and then draw that into the context.. but that seems "expensive" so hopefully there already exists a known and appropriate method