Page 4 of 6 FirstFirst ... 23456 LastLast
Results 61 to 80 of 113

Thread: How to set QWebEngineView on QQuickView

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

    Default Re: How to set QWebEngineView on QQuickView

    Thanks anda_skoa.
    But the problem now I am facing is that I am not able to select itself. only click events are detected in the WebEngineView (QML) after adding the mouse area to the WebEngineView
    Is there some restriction as in QWebEngineView in detecting MouseEvents.
    Last edited by ejoshva; 3rd July 2015 at 07:00.

  2. #62
    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: How to set QWebEngineView on QQuickView

    I am afraid I don't understand.

    Are you saying that the web view does not handle user mouse interaction such that the user can select text?

    Cheers,
    _

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

    Default Re: How to set QWebEngineView on QQuickView

    included the 'drag' in the mousearea and now I am able to select text

    Qt Code:
    1. WebEngineView {
    2. id: currentWebview
    3. objectName: "webView"
    4. url: "http://www.google.co.in"
    5. anchors.fill: parent
    6. readonly property string htmlContent: content
    7. onHtmlContentChanged: loadHtml(htmlContent, baseUrl);
    8.  
    9. MouseArea {
    10. id : mousearea
    11. anchors.fill: parent
    12. drag {
    13. target: currentWebview
    14. axis: Drag.XandYAxis
    15. }
    16.  
    17. onPressed: {
    18. pressPoint.x = mouseX
    19. pressPoint.y = mouseY
    20.  
    21. }
    22. onReleased: {
    23. releasePoint.x = mouseX
    24. releasePoint.y = mouseY
    25. console.log(releasePoint)
    26. }
    27. }
    28. onXChanged: {
    29. if(mousearea.drag.active){
    30. console.log("x : "+x)
    31. currentWebview.runJavaScript("window.getSelection()", function(result) { console.log("selected Text=" + result);} )
    32. }
    33. }
    34.  
    35. }
    To copy to clipboard, switch view to plain text mode 
    But I dont find any prints which I intended using console.log

    I am not find the drag to be consistant. Since, for 2 executions, I am able to select the text and the next execution it's not selectable. When I execute again, it's selectable.

    When the text is selected, no prints are got. when it's not selectable. prints are got.
    Last edited by ejoshva; 3rd July 2015 at 10:50.

  4. #64
    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: How to set QWebEngineView on QQuickView

    I don't understand your example.
    You are dragging the web view? how is that related to selection of text?

    Cheers,
    _

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

    Default Re: How to set QWebEngineView on QQuickView

    I didn't intend to drag the webview instead, I want to capture the mouse drag event and the text selection.
    So what should be the target in that case to enable selection.

  6. #66
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to set QWebEngineView on QQuickView

    Selection should work out of the box.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: How to set QWebEngineView on QQuickView

    It was working before including the mousearea inside WebEngineView.
    After including mousearea for WebEngineView, only clicks are available. Selection is non-existent.


    Added after 1 2 minutes:


    I am trying to use QWebEngineView as extended through qmlregistertype and not as QtWebEngine element WebEngineView as below

    Qt Code:
    1. //ReaderView.qml
    2. import QtQuick 2.4
    3. import QtQuick.Controls 1.3
    4. import WebView 1.0
    5.  
    6. Rectangle {
    7. id: rect1
    8. height: 800
    9. width : 1300
    10. color: "white"
    11.  
    12.  
    13. WebEngineView {
    14. id: currentWebview
    15. height : parent.height
    16. width : parent.width
    17. }
    18. }
    19.  
    20. //ReadWidget.cpp
    21. readwidget::readwidget(QWidget *parent) : QQuickWidget(parent)
    22. {
    23. engine = QQuickWidget::engine();
    24. root = this->rootContext();
    25.  
    26. /* Setting the current object into context of QML source */
    27. root->setContextProperty("rw", this);
    28.  
    29. /*Initializing the variables for the usage in QML*/
    30. Decrypt *decrypt = new Decrypt();
    31. QString content = decrypt->decryptFile("/Users/user/ssparklContent/LifeSciences_Grade1020151518_1963/Pages/10_chap05.html", 'A');
    32.  
    33. QUrl baseUrl = QUrl("file:///Users/user/ssparklContent/LifeSciences_Grade1020151518_1963/Pages/10_chap05.html");
    34. QVariant pgContent(content);
    35.  
    36. root->setContextProperty("content",pgContent);
    37. root->setContextProperty("baseUrl",baseUrl);
    38. qmlRegisterType<webview>("WebView", 1,0, "WebEngineView");
    39.  
    40. /* Setting the QML source as ReaderView.qml to be executed from
    41.   * current object */
    42. setSource(QUrl("qrc:/ReaderView.qml"));
    43. QQmlComponent component(engine);
    44. component.loadUrl(QUrl("qrc:/ReaderView.qml"));
    45. object = component.create(root);
    46.  
    47. setResizeMode(QQuickWidget::SizeRootObjectToView);
    48.  
    49. }
    To copy to clipboard, switch view to plain text mode 

    here getting error as below
    Invalid property assignment: "height" is a read-only property
    Invalid property assignment: "width" is a read-only property
    Last edited by ejoshva; 3rd July 2015 at 13:06.

  8. #68
    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: How to set QWebEngineView on QQuickView

    Quote Originally Posted by ejoshva View Post
    It was working before including the mousearea inside WebEngineView.
    After including mousearea for WebEngineView, only clicks are available. Selection is non-existent.
    What do you need the MouseArea for?
    Your code snippet doesn't say much in that regard.


    Quote Originally Posted by ejoshva View Post
    I
    I am trying to use QWebEngineView as extended through qmlregistertype and not as QtWebEngine element WebEngineView as below
    I think we've covered that in some other thread already (or it was someone with a very similar setup): QWebEngineView is a widget.
    It can (a) not be embedded in a QtQuick2 scene and (b) has no writable x/y/width/height properties (only writable geometry).

    Cheers,
    _

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

    Default Re: How to set QWebEngineView on QQuickView

    Quote Originally Posted by anda_skoa View Post
    What do you need the MouseArea for?
    Your code snippet doesn't say much in that regard.
    I want to replicate the mouseEvents that we have in the QWebEngineView (i.e.) highlight the selected text, scroll to view the searched text on the page.

    Exact requirement is on mouse release, I will show a context Menu (highlight, annot). On selecting highlight, the selected text will be highlighted, on selecting annot, annot text box will open up for user input; also the selected text will be highlighted.

    I will also be doing a search on the page by getting user input, upon finding the word on the page have to scroll that line to viewable part of the screen.


    Quote Originally Posted by anda_skoa View Post
    I think we've covered that in some other thread already (or it was someone with a very similar setup): QWebEngineView is a widget.
    It can (a) not be embedded in a QtQuick2 scene and (b) has no writable x/y/width/height properties (only writable geometry).
    by bad
    missed the part. I remember this one.

  10. #70
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to set QWebEngineView on QQuickView

    Let's summarize the current situation. What exactly are you using as your web view? What exactly does the scene look like? What is the relation between the web view item and the MouseArea item (if any)? And finally, what is the ultimate goal you are trying to achieve?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: How to set QWebEngineView on QQuickView

    Quote Originally Posted by wysota View Post
    Let's summarize the current situation. What exactly are you using as your web view?
    QtWebEngine
    QML WebEngineView
    Quote Originally Posted by wysota View Post
    What exactly does the scene look like?
    There is a QQuickWidget in which Qml is included using setSource().
    this QML has the QtWebEngine's element WebEngineView defined in it.
    Quote Originally Posted by wysota View Post
    What is the relation between the web view item and the MouseArea item (if any)?
    I want to emulate the QMouseEvents of the WebView in the Qml WebEngineView.
    So included the MouseArea to capture the mouse events.
    Quote Originally Posted by wysota View Post
    And finally, what is the ultimate goal you are trying to achieve?
    What I am trying to achieve is to show a context Menu (highlight, annot) on mouse drag release (selecting text on the page loaded on the WebEngineView). On selecting highlight, the selected text will be highlighted, on selecting annot, annot text box will open up for user input; also the selected text will be highlighted.

    I will also be doing a search on the page by getting user input, upon finding the word on the page have to scroll that line to viewable part of the screen.
    Last edited by ejoshva; 4th July 2015 at 02:13.

  12. #72
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to set QWebEngineView on QQuickView

    Quote Originally Posted by ejoshva View Post
    I want to emulate the QMouseEvents of the WebView in the Qml WebEngineView.
    So included the MouseArea to capture the mouse events.
    What do you mean by that? WebEngineView already handles mouse events without any additional items on top of it.


    What I am trying to achieve is to show a context Menu (highlight, annot) on mouse drag release (selecting text on the page loaded on the WebEngineView).
    On "mouse drag release" or rather when text selection on a page changes? What if someone selects text by double or tripple clicking?

    Does that help you in any way?

    http://forums.mozillazine.org/viewto...?f=25&t=198568

    On selecting highlight, the selected text will be highlighted, on selecting annot, annot text box will open up for user input; also the selected text will be highlighted.
    What is annot? What HTML element is used to display that on a web page?

    I will also be doing a search on the page by getting user input, upon finding the word on the page have to scroll that line to viewable part of the screen.
    I don't think WebEngineView contains API that could do it.

    Tell me one more thing, why are you using Qt Quick at all if you just have a single static item on the scene? QWebEngineView has much richer API and subclassing it would probably let you use much more of its functionality.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: How to set QWebEngineView on QQuickView

    Quote Originally Posted by wysota View Post
    What do you mean by that? WebEngineView already handles mouse events without any additional items on top of it.
    In that case, how do I do the customized action like what can be done on mouseReleaseEvent(), mousePressEvent().

    Quote Originally Posted by wysota View Post
    On "mouse drag release" or rather when text selection on a page changes? What if someone selects text by double or tripple clicking?
    Does that help you in any way?
    http://forums.mozillazine.org/viewto...?f=25&t=198568.
    I am taking into account the text selection only on single click, hold, drag to select the text and release.
    Quote Originally Posted by wysota View Post
    What is annot? What HTML element is used to display that on a web page?.
    Annotation, I have the code to display the annotations.

    Quote Originally Posted by wysota View Post
    I don't think WebEngineView contains API that could do it..
    For search too, have implemented functions to do the same.

    Quote Originally Posted by wysota View Post
    Tell me one more thing, why are you using Qt Quick at all if you just have a single static item on the scene? QWebEngineView has much richer API and subclassing it would probably let you use much more of its functionality.
    I have much more items on the ReaderView.qml, WebEngineView is just an item.

    In nutshell, I am trying to do a e-reader but in real it's browser where in html or xhtml pages are loaded. But the functionalities of the e-reader are implemented.
    Last edited by wysota; 4th July 2015 at 08:33.

  14. #74
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to set QWebEngineView on QQuickView

    Quote Originally Posted by ejoshva View Post
    In that case, how do I do the customized action like what can be done on mouseReleaseEvent(), mousePressEvent().
    You put a mouse area over the item and handle things there. But you don't have to repeat what the view already handles itself. Just pass in the events you are not handling yourself in the mouse area.

    Annotation, I have the code to display the annotations.
    Shouldn't you be implementing everything in HTML then?

    For search too, have implemented functions to do the same.
    Where did you implement that?

    I have much more items on the ReaderView.qml, WebEngineView is just an item.
    Telling one thing in one post and then telling a different thing in another post doesn't help to solve the problem:

    Quote Originally Posted by wysota
    What exactly does the scene look like?
    There is a QQuickWidget in which Qml is included using setSource().
    this QML has the QtWebEngine's element WebEngineView defined in it.
    In nutshell, I am trying to do a e-reader but in real it's browser where in html or xhtml pages are loaded. But the functionalities of the e-reader are implemented.
    IMO all you want can easily be done in HTML which you already have instead of struggling to do it in Qt Quick. You can equip your page with required facilities to communicate with Qt Quick (e.g. using QWebChannel), do the things which are simple to do in HTML and pass enough information to Qt Quick to do the rest there (e.g. show a context menu).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    Default Re: How to set QWebEngineView on QQuickView

    I have implemented that search in C++.

    Regarding mouse Events, I am not able to find how to do this
    You put a mouse area over the item and handle things there. But you don't have to repeat what the view already handles itself. Just pass in the events you are not handling yourself in the mouse area.
    If I am doing everything in HTML, nativity will be a problem.

  16. #76
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to set QWebEngineView on QQuickView

    Quote Originally Posted by ejoshva View Post
    I have implemented that search in C++.
    And how did you merge that with WebEngineView?

    Regarding mouse Events, I am not able to find how to do this
    Either ignore the events you don't handle yourself and/or configure MouseArea to only react to a subset of buttons. Events for remaining buttons will be ignored automatically.

    If I am doing everything in HTML, nativity will be a problem.
    I have no idea what you mean by that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  17. #77
    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: How to set QWebEngineView on QQuickView

    Quote Originally Posted by ejoshva View Post
    Regarding mouse Events, I am not able to find how to do this
    I think if you set the "accepted" property of the MouseEvent to "false" it will be passed onto the item below the mouse area.

    Cheers,
    _

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

    Default Re: How to set QWebEngineView on QQuickView

    Below is my WebEngineView (QML) . If the selection is enabled, then this mousearea is not considered. When the mousearea is active, selection is inactive.

    I dont understand, why fewer times, mousearea defined inside WebEngineView is enabled and rest of times mousearea defined is not enabled.


    Qt Code:
    1. WebEngineView {
    2. id: currentWebview
    3. objectName: "webView"
    4. url: "http://www.google.co.in"
    5. anchors.fill: parent
    6. readonly property string htmlContent: content
    7. onHtmlContentChanged: loadHtml(htmlContent, baseUrl);
    8.  
    9. MouseArea {
    10. id : mousearea
    11. anchors.fill: parent
    12. drag {
    13. id : weDrag
    14. target: currentWebview
    15. }
    16.  
    17. onPressed: {
    18. pressPoint.x = mouseX
    19. pressPoint.y = mouseY
    20. console.log("PressPoint : "+pressPoint)
    21. }
    22. onReleased: {
    23. releasePoint.x = mouseX
    24. releasePoint.y = mouseY
    25. console.log("releasePoint : "+releasePoint)
    26. if(pressPoint != releasePoint )
    27. {
    28. currentWebview.runJavaScript("window.getSelection()", function(result) { console.log("selected Text=" + result);} )
    29. }
    30. }
    31. }
    32. }
    To copy to clipboard, switch view to plain text mode 


    Added after 10 minutes:


    Quote Originally Posted by wysota View Post
    You put a mouse area over the item and handle things there. But you don't have to repeat what the view already handles itself. Just pass in the events you are not handling yourself in the mouse area.
    how do pass in the events which I am not handling.
    in QGraphicsWebView, we pass in the mouse events as QGraphicsWebView::mousePresses(event).

    Here how do I do the same.

    Also I am not able to capture the selected text.
    how can I do that.
    Qt Code:
    1. onReleased: {
    2. releasePoint.x = mouseX
    3. releasePoint.y = mouseY
    4. console.log("releasePoint : "+releasePoint)
    5. if(pressPoint != releasePoint )
    6. {
    7. currentWebview.runJavaScript("window.getSelection()", function(result) { console.log("selected Text=" + result);} )
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 

    I tried something as above, when this signal is captured, selection is not enabled.
    When selection is enabled, this signal (ie) mousearea defined is not enabled
    Last edited by ejoshva; 7th July 2015 at 12:18.

  19. #79
    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: How to set QWebEngineView on QQuickView

    So letting the events pass by setting their accepted flag to false did not work?

    Cheers,
    _

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

    Default Re: How to set QWebEngineView on QQuickView

    Qt Code:
    1. onPressed: {
    2. pressPoint.x = mouseX
    3. pressPoint.y = mouseY
    4. console.log("PressPoint : "+pressPoint)
    5. acceptedButtons : false
    6.  
    7. }
    To copy to clipboard, switch view to plain text mode 

    This is how I did and it didn't work.

Similar Threads

  1. Loading QDeclarativeView in QWebEngineView
    By ejoshva in forum Newbie
    Replies: 8
    Last Post: 7th May 2015, 09:38
  2. Replies: 8
    Last Post: 23rd April 2015, 12:17
  3. QQuickView or QQmlApplicationEngine or QQuickWidget
    By ustulation in forum Qt Quick
    Replies: 0
    Last Post: 18th January 2015, 13:16
  4. Repaint a QML Scene (QQuickView)
    By alizadeh91 in forum Qt Programming
    Replies: 0
    Last Post: 23rd July 2013, 09:54
  5. Set fixed window size with QQuickView
    By cristeab in forum Qt Quick
    Replies: 1
    Last Post: 31st January 2013, 10:25

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.