I have qml file with a webview in it. I get a reference to that object in c++ but is QObject* Can i cast it to something similar to QWebView from which i can get the QWebPage object and so? qobject_cast<> returns NULL if i try QWebView. It works with cast to QQuickItem but that doesn't really help me much.
Thanks
You can't. The QML WebView element doesn't have a public C++ API. You have two ways to work around this:
Then include the private headers:
Now you can access the WebView, as long as you get a pointer to it (for example by using
QObject::findChildren
or by passing theQObject*
from QML to C++. Here I simply assume the WebView is the root object, for simplicity):QObject
API to access the WebView's properties: