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
Qt Code:
  1. ReaderView::ReaderView(QWidget *parent)
  2. : QQuickWidget(parent)
  3. {
  4. decrypt = new Decrypt();
  5. webView = new WebEngineView();
  6. context = this->rootContext();
  7. context->setContextProperty("rw",this);
  8. qmlRegisterType<WebEngineView>("WebView",1,0,"WebEngineView");
  9. setSource(QUrl("qrc:/ReaderView.qml"));
  10. QQmlComponent component(engine());
  11. component.loadUrl(QUrl("qrc:/ReaderView.qml"));
  12. object = component.create(context);
  13. qDebug()<<component.errors();
  14. displayPage();
  15. }
  16.  
  17. void ReaderView::displayPage()
  18. {
  19. QString content = decrypt->decryptFile("/Users/user/ssparklContent/CUPIGrade6-20150519_1977/Pages/05_preface.html", 'A');
  20. QUrl url = QUrl("file:///Users/user/ssparklContent/CUPIGrade6-20150519_1977/Pages/05_preface.html");
  21. QMetaObject::invokeMethod(object, "loadpage",Q_ARG(QVariant,content),Q_ARG(QVariant,url));
  22. }
  23.  
  24. WebEngineView::WebEngineView(QWidget *parent)
  25. : QWebEngineView(parent)
  26. {
  27. setGeometry(0,0,1300,800);
  28. }
  29. void WebEngineView::setCurrentPage(QString content, QUrl baseUrl)
  30. {
  31. // setHtml(content,baseUrl);
  32. }
  33.  
  34. //ReaderView.qml
  35. import QtQuick 2.0
  36. Rectangle {
  37. id: rect1
  38. height: 800
  39. width: 1300
  40. color: "white"
  41. function loadpage(pgcontent,url)
  42. {
  43. browserwindow.loadCurrentPage(pgcontent,url)
  44. }
  45. BrowserWindow {
  46. id: browserwindow
  47. height: parent.height - 30
  48. width:parent.width
  49. y:15
  50. clip:true
  51. }
  52. }
  53.  
  54. //BrowserWindow.qml
  55. import QtQuick 2.0
  56. import WebView 1.0
  57.  
  58.  
  59. Rectangle {
  60. id:flick
  61. height: parent.height
  62. width: parent.width - 5
  63.  
  64. function loadCurrentPage(pagecontents, url)
  65. {
  66. webEngineView.setCurrentPage(pagecontents,url)
  67.  
  68. }
  69.  
  70.  
  71. WebEngineView {
  72. id: webEngineView
  73. // height: parent.height
  74. // width: parent.width
  75.  
  76. }
  77. }
To copy to clipboard, switch view to plain text mode