I would like to use Blink (or Webkit, Gecko, KHTML, ... any similar layout engine; I'm not fussy) as a layout engine for rendering structured data from a C++ program. And I want to be able to bind functions to DOM events in order to respond to user interactions.
In other words, I don't want to use the HTTP protocol, Javascript, or even URIs for image resources (I'm planning to pipe images and video content from a database into the DOM directly, assuming that's possible). I just want a layout engine that will let me assemble the DOM tree from scratch via C++ function calls, and let me bind function pointers to user interaction events.
I'm having a lot of trouble finding information on how to do this. A lot of information out there seems to be focussed on higher level web-browsery stuff, like embedding a full-featured web browser frame within an application. I'm wondering if there's some kind of 'minimal subset' of a browser engine out there that I could use, and what might be the quickest/easiest way to get started.
You may try WebKit Widget examples here.
With the Qt WebEngine (which uses blink) you get a web browser which you can feed data into from the containing application (described at: http://doc.qt.io/qt-5/qtwebkit-bridge.html). You can give it the document as a pre-formed QWebEnginePage instance, and you can make objects from the containing program available to JavaScript running in the page. Therefore, it is possible to display a dynamic web page without ever accessing files or URIs.
In order to use this Qt-WebKit bridge you need to provide the data you want to access as QObject-derived classes, and you will need to run the qmake tool in your build process because it relies on the Qt meta-object compiler, so you do get a little sucked into the world of Qt.
Also, I'm not sure what project you're working on but I should mention that Qt Quick is also worth a look - it does a similar thing (renders a graphical application using a web browser which can contain JavaScript), but instead of HTML it uses a nice JSON-like declarative language called QML. You can see an overview of its capabilities here: http://doc.qt.io/qt-5/qmlapplications.html .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With