Results 1 to 6 of 6

Thread: Issue with loading a html page on QWebEngienView through extension onto QML

  1. #1
    Join Date
    Feb 2015
    Posts
    185
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default 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
    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 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Issue with loading a html page on QWebEngienView through extension onto QML

    Quote Originally Posted by ejoshva View Post
    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,
    _

  3. #3
    Join Date
    Feb 2015
    Posts
    185
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default 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)

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

  5. #5
    Join Date
    Feb 2015
    Posts
    185
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: Issue with loading a html page on QWebEngienView through extension onto QML

    Quote Originally Posted by anda_skoa View Post
    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.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Issue with loading a html page on QWebEngienView through extension onto QML

    There is currently no standard QQuickItem based proxy for widgets.

    Cheers,
    _

Similar Threads

  1. Replies: 3
    Last Post: 10th June 2015, 07:15
  2. Replies: 0
    Last Post: 10th April 2015, 08:54
  3. How to Communicate between Qt and a HTML page
    By AbinaThomas in forum Qt Programming
    Replies: 0
    Last Post: 27th August 2012, 08:50
  4. jump from one html page to another html page
    By RENOLD in forum Qt Programming
    Replies: 4
    Last Post: 10th February 2012, 05:41
  5. QML extension - painting issue
    By kornicameister in forum Qt Quick
    Replies: 5
    Last Post: 5th October 2011, 08:39

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.