I am porting from QGraphicsView to QQuickView.
Like we load QGraphicsWebView on QGraphicsView, how to load QWebEngineView on QQuickView.
currently I am setting it like below but it's not getting loaded.
QuickViewReader::QuickViewReader(QWindow *parent): QQuickView(parent)
{
WebView = new WebEngineView();
root = new QQmlContext(engine.rootContext());
qmlRegisterType<WebEngineView>("WebView", 1,0, "WebEngineView");
/* Setting the current object into context of QML source */
root->setContextProperty("rw", this);
this->rootContext()->setContextProperty("rw", this);
/* Setting the webview object into context of QML source */
root->setContextProperty("webView",this->WebView);
QQmlComponent component(&engine);
component.
loadUrl(QUrl("qrc:/ReaderView.qml"));
object = component.create(root);
setSource
(QUrl("qrc:/ReaderView.qml"));
setResizeMode(QQuickView::SizeRootObjectToView);
}
QuickViewReader::QuickViewReader(QWindow *parent): QQuickView(parent)
{
WebView = new WebEngineView();
root = new QQmlContext(engine.rootContext());
qmlRegisterType<WebEngineView>("WebView", 1,0, "WebEngineView");
/* Setting the current object into context of QML source */
root->setContextProperty("rw", this);
this->rootContext()->setContextProperty("rw", this);
/* Setting the webview object into context of QML source */
root->setContextProperty("webView",this->WebView);
QQmlComponent component(&engine);
component.loadUrl(QUrl("qrc:/ReaderView.qml"));
object = component.create(root);
setSource(QUrl("qrc:/ReaderView.qml"));
setResizeMode(QQuickView::SizeRootObjectToView);
}
To copy to clipboard, switch view to plain text mode
The page is blank.
When I explicitly call WebView.show(), the page is displayed.
How to overlay QWebEngineView on QQuickView
Bookmarks