I didn't realize that. Thanks for pointing out that.
Now have modified it.
ReaderView::ReaderView()
{
QQmlContext *context = new QQmlContext(this->rootContext());
context->setContextProperty("rdView",this);
context->setContextProperty("content",content);
setSource
(QUrl("qrc:/Main.qml"));
}
WebEngineView {
id: currentWebView
url: "http://www.google.co.in"
anchors.fill: parent
readonly property string htmlContent: content
onHtmlContentChanged: loadHtml(htmlContent, rdView.getBaseUrl());
}
ReaderView::ReaderView()
{
QQmlContext *context = new QQmlContext(this->rootContext());
context->setContextProperty("rdView",this);
context->setContextProperty("content",content);
setSource(QUrl("qrc:/Main.qml"));
}
WebEngineView {
id: currentWebView
url: "http://www.google.co.in"
anchors.fill: parent
readonly property string htmlContent: content
onHtmlContentChanged: loadHtml(htmlContent, rdView.getBaseUrl());
}
To copy to clipboard, switch view to plain text mode
But I am getting error as
qrc:/Main.qml:18: ReferenceError: content is not defined
qrc:/Main.qml:19: TypeError: Property 'getBaseUrl' of object QQuickWidget(0x7fe328f0eb40) is not a function
qrc:/Main.qml:18: ReferenceError: content is not defined
Not sure, what I am missing
Added after 7 minutes:
Got it working by setting as property.
WebEngineView {
id: currentWebView
url: "http://www.google.co.in"
anchors.fill: parent
readonly property string htmlContent: content
onHtmlContentChanged: loadHtml(htmlContent, baseUrl);
}
ReaderView::ReaderView()
{
Decrypt *decrypt = new Decrypt();
QString content
= decrypt
->decryptFile
("/Users/user/learnOnContent/LifeSciences_Grade1020151518_1963/Pages/pag001.html",
'A');
setHtmlContent(content);
QUrl baseUrl
= QUrl("file:///Users/user/ssparklBookStore/LifeSciences_Grade1020151518_1963/Pages/pag001.html");
setBaseUrl(baseUrl);
QQmlContext *context = this->rootContext();
context->setContextProperty("rdView",this);
context->setContextProperty("content",qv);
context->setContextProperty("baseUrl",baseUrl);
setSource
(QUrl("qrc:/Main.qml"));
}
WebEngineView {
id: currentWebView
url: "http://www.google.co.in"
anchors.fill: parent
readonly property string htmlContent: content
onHtmlContentChanged: loadHtml(htmlContent, baseUrl);
}
ReaderView::ReaderView()
{
Decrypt *decrypt = new Decrypt();
QString content = decrypt->decryptFile("/Users/user/learnOnContent/LifeSciences_Grade1020151518_1963/Pages/pag001.html", 'A');
setHtmlContent(content);
QUrl baseUrl = QUrl("file:///Users/user/ssparklBookStore/LifeSciences_Grade1020151518_1963/Pages/pag001.html");
setBaseUrl(baseUrl);
QQmlContext *context = this->rootContext();
context->setContextProperty("rdView",this);
QVariant qv(content);
context->setContextProperty("content",qv);
context->setContextProperty("baseUrl",baseUrl);
setSource(QUrl("qrc:/Main.qml"));
}
To copy to clipboard, switch view to plain text mode
Thanks anda_skoa
Bookmarks