Issue with loading a html page on QWebEngienView through extension onto QML
have a QQuickWidget(ReaderMain.cpp) which has a qml (ReaderView.qml) . Also I have a QWebEngineView (WebEngineView.cpp). This WebEngineView I have extended to the qml through QMLREGISTERTYPE in ReaderMain.cpp and it's defined in another QML(BrowserWindow.qml) which is in turn included in ReaderView.qml.
Now When I try to load a page using SetHtml(). Page is not getting loaded.
I am not able to set the width and height for the WebEngineView in the QML.
error thrown as read-only property.
Kindly let me know, how can I make the page loaded and display it.
code is as below
Code:
ReaderView
::ReaderView(QWidget *parent
) : QQuickWidget(parent)
{
decrypt = new Decrypt();
webView = new WebEngineView();
context = this->rootContext();
context->setContextProperty("rw",this);
qmlRegisterType<WebEngineView>("WebView",1,0,"WebEngineView");
setSource
(QUrl("qrc:/ReaderView.qml"));
QQmlComponent component(engine());
component.
loadUrl(QUrl("qrc:/ReaderView.qml"));
object = component.create(context);
qDebug()<<component.errors();
displayPage();
}
void ReaderView::displayPage()
{
QString content
= decrypt
->decryptFile
("/Users/user/ssparklContent/CUPIGrade6-20150519_1977/Pages/05_preface.html",
'A');
QUrl url
= QUrl("file:///Users/user/ssparklContent/CUPIGrade6-20150519_1977/Pages/05_preface.html");
}
WebEngineView
::WebEngineView(QWidget *parent
) : QWebEngineView(parent)
{
setGeometry(0,0,1300,800);
}
void WebEngineView
::setCurrentPage(QString content,
QUrl baseUrl
) {
// setHtml(content,baseUrl);
}
//ReaderView.qml
import QtQuick 2.0
Rectangle {
id: rect1
height: 800
width: 1300
color: "white"
function loadpage(pgcontent,url)
{
browserwindow.loadCurrentPage(pgcontent,url)
}
BrowserWindow {
id: browserwindow
height: parent.height - 30
width:parent.width
y:15
clip:true
}
}
//BrowserWindow.qml
import QtQuick 2.0
import WebView 1.0
Rectangle {
id:flick
height: parent.height
width: parent.width - 5
function loadCurrentPage(pagecontents, url)
{
webEngineView.setCurrentPage(pagecontents,url)
}
WebEngineView {
id: webEngineView
// height: parent.height
// width: parent.width
}
}
Re: Issue with loading a html page on QWebEngienView through extension onto QML
Quote:
Originally Posted by
ejoshva
have a QQuickWidget(ReaderMain.cpp) which has a qml (ReaderView.qml) . Also I have a QWebEngineView (WebEngineView.cpp). This WebEngineView I have extended to the qml through QMLREGISTERTYPE in ReaderMain.cpp and it's defined in another QML(BrowserWindow.qml) which is in turn included in ReaderView.qml.
Probably a typo, but QWebEngineView is the widget base view for QtWebEngine.
I.e. it is derived from QWidget, not QQuickItem.
All elements that need to be part of the visualization in a QtQuick2 scene need to be derived (directly or indirectly) from QQuickItem.
Cheers,
_
Re: Issue with loading a html page on QWebEngienView through extension onto QML
In that case, I wont be able to use QML elements as well.
Saw the below link explaining the same
http://stackoverflow.com/questions/1...-in-qt-quick-2
I have the components already available in QML.
Please let me know, how to include those elements in QWebEngineView which is QWidget based.
For example, on mouse release on the WebEngineView, catching the same through event filter installed on the child, I will be displaying a context menu (context menu is a page in QML)
Re: Issue with loading a html page on QWebEngienView through extension onto QML
Well, there are a couple of options:
1) as the stack overflow thread suggest, using a proxy to between the widget and the QtQuick2 scene
2) putting a QQuickWidget on top of the web view widget
3) using QQuickView based sub windows, e.g. for the context popup, dialogs, with the main view widget based
4) using the QQuickItem based web engine UI
Cheers,
_
Re: Issue with loading a html page on QWebEngienView through extension onto QML
Quote:
Originally Posted by
anda_skoa
Well, there are a couple of options:
1) as the stack overflow thread suggest, using a proxy to between the widget and the QtQuick2 scene
_
To make use of this proxy, only QGraphicsProxyWidget which is of used to set QWidgets onto QGraphicsScene is available.
Is there something similar available for QtWebEngine.
Re: Issue with loading a html page on QWebEngienView through extension onto QML
There is currently no standard QQuickItem based proxy for widgets.
Cheers,
_