I found the answer. Basically, in Qt5.5, I'm diving into experimental land with QtWebView. The class methods are largely undocumented and may change in the future.
For now, the only technique is message passing, not native C++ class method invocation like you could use in the QWebView C++ Bridge. The QWebView C++ Bridge only works with QWebView widgets, not the QtWebView QML. So, you do this message passing with navigator.qt.postMessage()
API from your Javascript to your QML, and then QML can call C++. In order to get that extra functionality, you'll need to do a few steps. Here's an example:
Invoke C++ method from webviews Javascript
This is blogged a little here:
http://rschroll.github.io/beru/2013/08/21/qtwebview.experimental.html
As you can see from the example, you have to add these imports to your main.qml:
import QtWebKit 3.0
import QtWebKit.experimental 1.0
Then, in your WebView{}
section, you have to add this line:
experimental.preferences.navigatorQtObjectEnabled: true
At that point, you can call navigator.qt.postMessage("call foo in C++");
to send a message to the QML, which you can then pick up inside your WebView{}
section with:
experimental.onMessageReceived: { ...do something here in the QML... }
Your QML can then pass a message right back to the Javascript with:
experimental.postMessage("okay, I called foo in C++")
And then in your Javascript you can add an event listener like so:
navigator.qt.onmessage = function(ev) {
$('BODY').prepend(ev.data); // since console.log() is not possible
}
As for how to get your QML to call C++, here's an example:
https://stackoverflow.com/a/17881019/105539
EDIT: After more experimentation in Qt 5.5 with QtWebView, it appears fairly flaky in the following respects. I don't recommend it in 5.5 -- it's not ready for primetime. In Qt 5.5, you're better off using the QWebView widget for now and then migrate to QtWebEngine when the next version of Qt comes out (Qt 5.6, 5.7?).
By default, it gives you a rightclick context menu you may not want. Interestingly, you can turn it off if you import the experimental library and then set this property in your QML: experimental.preferences.navigatorQtObjectEnabled: true
.
By default, HTML5 postMessage() API (the one native with HTML5) doesn't appear to work unless you enable experimental.preferences.navigatorQtObjectEnabled: true
.
When you enable experimental.preferences.navigatorQtObjectEnabled: true
, the scrollbars disappear if you enabled them on some HTML page elements, the checkboxes and radio buttons look extremely funky, and popdown select listboxes stopped working.
When you doubleclick a page, it zooms it.