Using Blink as an external interface mechanism - where to start?

I would like to use Blink (or Webkit, Gecko, KHTML, ... any similar linking mechanism, I'm not fussy) as a linking mechanism 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 do not want to use the HTTP protocol, Javascript, or even a URI for image resources (I plan to directly connect images and video content from the database to the DOM, assuming this is possible). I just want the linking mechanism to allow me to build the DOM tree from scratch through calls to C ++ functions and allow me to bind function pointers to user interaction events.

I have many problems finding information on how to do this. Most of the information seems to be focused on a higher level web browser, such as embedding a fully functional web browser in an application. I am wondering if there is some “minimal subset” in the browser that I could use, and which might be the fastest / easiest way to get started.

+5
source share
2 answers

With Qt WebEngine (which uses blinking), you get a web browser into which you can paste data from the containing application (described in: http://doc.qt.io/qt-5/qtwebkit-bridge.html ). You can provide the document as a pre-formed instance of QWebEnginePage, and you can make the objects from the contained program available for JavaScript running on the page. Thus, it is possible to display a dynamic web page without access to files or URIs.

To use this Qt-WebKit bridge, you need to provide the data you want to receive, like QObject-based classes, and you will need to run the qmake tool during the build process, as it relies on the Qt meta-object compiler, so you get a little pulled into the world Qt.

In addition, I'm not sure what project you are 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 that may contain JavaScript), but instead of HTML, it uses good A JSON-like declarative language called QML. Here you can familiarize yourself with its capabilities: http://doc.qt.io/qt-5/qmlapplications.html .

+1
source

You can try WebKit Widget examples here .

+1
source

Source: https://habr.com/ru/post/1202120/


All Articles