ejoshva
19th June 2015, 10:52
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
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");
QMetaObject::invokeMethod(object, "loadpage",Q_ARG(QVariant,content),Q_ARG(QVariant,url));
}
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
}
}
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
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");
QMetaObject::invokeMethod(object, "loadpage",Q_ARG(QVariant,content),Q_ARG(QVariant,url));
}
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
}
}