7

With QtWebkit it is possible to expose C++ objects to Javascript via QWebFrame::addToJavaScriptWindowObject as described in https://stackoverflow.com/a/20685002/595937

Can the same thing be accomplished in Qt 5.4 using QtWebEngine?

Community
  • 1
  • 1
ljcundiff
  • 1,159
  • 1
  • 9
  • 14

1 Answers1

10

Exporting C++ objects to HTML/JS is not directly possible with QWebEngine.

Instead, the newly introduced QWebChannel provides a bridge between HTML/JS and C++. Have a look at the documentation, especially at the examples. There was also a quite good introductory talk about QWebChannel at this year's Qt Developer Days, which might also be of interest to you. The videos of the talks will go online in a few weeks.

Thomas McGuire
  • 5,308
  • 26
  • 45
  • @ThomasMcGuire The link provided in your text is probably rotten. I believe this is the current working: [`QWebChannel` (Qt5)](http://doc.qt.io/qt-5/qwebchannel.html). – Scheff's Cat Apr 08 '17 at 18:33
  • @Scheff: Thanks for notifying me about the broken URL, I've updated it now. – Thomas McGuire Apr 09 '17 at 21:33