Page 6 of 6 FirstFirst ... 456
Results 101 to 113 of 113

Thread: How to set QWebEngineView on QQuickView

  1. #101
    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 included in OnReleased
    If an object doesn't get a "pressed" signal, it will not receive a "released" signal. Only an object which accepted a 'pressed' signal will get it. You have to pass the 'pressed' signal for selection to work.
    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.


  2. #102
    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. WebEngineView {
    2. id: currentWebview
    3. objectName: "webView"
    4. anchors.fill: parent
    5. readonly property string htmlContent: content
    6. onHtmlContentChanged: loadHtml(htmlContent, baseUrl);
    7.  
    8. MouseArea {
    9. id : mousearea
    10. anchors.fill: parent
    11.  
    12. onPressed: {
    13. pressPoint.x = mouseX
    14. pressPoint.y = mouseY
    15. [B] mouse.accepted = true[/B]
    16. }
    17. onReleased: {
    18. releasePoint.x = mouseX
    19. releasePoint.y = mouseY
    20. if(pressPoint != releasePoint )
    21. {
    22. cntxtMenu.x = releasePoint.x - 74
    23. cntxtMenu.y = releasePoint.y - 30
    24. cntxtMenu.visible = true
    25. [B]mouse.accepted = true[/B]
    26. currentWebview.runJavaScript("window.getSelection()", function(result) { console.log("selected Text =" + result.toString());} )
    27. }
    28. }
    29. }
    30. }
    To copy to clipboard, switch view to plain text mode 

    I have included as accepted = true, still I dont get the selection


    Added after 45 minutes:


    Quote Originally Posted by wysota View Post
    If an object doesn't get a "pressed" signal, it will not receive a "released" signal. Only an object which accepted a 'pressed' signal will get it. You have to pass the 'pressed' signal for selection to work.
    I have included the mouse.pressed = true in mousePressed as well, still selection not available
    Last edited by ejoshva; 9th July 2015 at 12:52.

  3. #103
    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
    I have included the mouse.pressed = true in mousePressed as well, still selection not available
    I don't know, in all languages that I know about, the meaning of "true" is not the same meaning as "false".
    It is definitely not the case for JavaScript.

    Cheers,
    _

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

    Default Re: How to set QWebEngineView on QQuickView

    to pass on to webview, it should be true as per the docs.

    I will have to define by own logic, when I set it to false.

    I kept mouse.accepted = false for both mousepressed and mousereleased, then the selection is available.

    Now how to get the text selection meaning on which event? since the control doesn't reach mousearea.

    once selection is done, I will have to bring up the context menu.

    Which event should be captured??

    on WebView or mousearea, I should look to capture the drag event.

    the text is selected on the page loaded on webview, (i.e.) it's child rite. May be I am wrong in this.
    Last edited by ejoshva; 9th July 2015 at 14:10.

  5. #105
    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
    to pass on to webview, it should be true as per the docs.
    Which docs?


    Quote Originally Posted by ejoshva View Post
    I kept mouse.accepted = false for both mousepressed and mousereleased, then the selection is available.
    As expected

    Quote Originally Posted by ejoshva View Post
    Now how to get the text selection meaning on which event? since the control doesn't reach mousearea.
    What "control" doesn't reach mouse area?

    Quote Originally Posted by ejoshva View Post
    once selection is done, I will have to bring up the context menu.
    Which event should be captured??
    Mouse Release ends the selection, no?
    So you get the release first, you set up a delayed trigger, you let the event pass to the web view, you get the selection in the delayed trigger.

    Quote Originally Posted by ejoshva View Post
    on WebView or mousearea, I should look to capture the drag event.
    No, drag is something entirely different.

    Cheers,
    _

  6. #106
    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
    Which docs?
    mouseevent#accepted
    Quote Originally Posted by anda_skoa View Post
    What "control" doesn't reach mouse area?
    I have capture the mousePressed point and trying to compare that with the mouseRelease point to bring up the context menu.
    But I am not able to capture the mousePressed Point in the mousePressed event defined in the MouseArea.

    Quote Originally Posted by anda_skoa View Post
    Mouse Release ends the selection, no?
    So you get the release first, you set up a delayed trigger, you let the event pass to the web view, you get the selection in the delayed trigger.
    I have already included ContextMenu.visible = true in OnReleased.
    But it doesn't show up when the accepted is false.

    When the accepted is false, whatever I write in mouseArea events like onpressed, onreleased doesn't get executed.

    In that case, where do I have to capture them. Please bare with me for asking this again.

    What is a delayed trigger ?


    Quote Originally Posted by anda_skoa View Post
    No, drag is something entirely different.
    Yes I get it.

  7. #107
    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
    Let me quote these docs and highlight the relevant part: Setting accepted to true prevents the mouse event from being propagated to items below this item.

    I have capture the mousePressed point and trying to compare that with the mouseRelease point to bring up the context menu.
    What for? Does the decision of showing a context menu depend on the distance between press and release?

    But I am not able to capture the mousePressed Point in the mousePressed event defined in the MouseArea.
    Why not? I think my example code demonstrates how to do that.

    I have already included ContextMenu.visible = true in OnReleased.
    But it doesn't show up when the accepted is false.
    What do you mean? Does the code execute but does nothing or does the code not execute at all? I would expect that onReleased of the overlay MouseArea might not execute if you cleared the accepted flag on the press event because of what I said a couple of posts earlier. Did you verify that?

    When the accepted is false, whatever I write in mouseArea events like onpressed, onreleased doesn't get executed.
    Did you run my example from post #90? Can you modify my example to demonstrate 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.


  8. #108
    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 for? Does the decision of showing a context menu depend on the distance between press and release?
    Yes, if the pressed point and released point are not same, I will show the context menu at the released point.

    Quote Originally Posted by wysota View Post
    Why not? I think my example code demonstrates how to do that.
    Even from your example, I get only the mousePressed event.
    Quote Originally Posted by wysota View Post
    What do you mean? Does the code execute but does nothing or does the code not execute at all? I would expect that onReleased of the overlay MouseArea might not execute if you cleared the accepted flag on the press event because of what I said a couple of posts earlier. Did you verify that?
    I control doesnt reach the mouseReleased event itself. Only in mouseReleased, I am setting it to visible.

    Quote Originally Posted by wysota View Post
    Did you run my example from post #90? Can you modify my example to demonstrate that?
    [/QUOTE] yes, QMLWebEngineTest.zip

    Have attached the whole project making use of the QML code you gave.

    Here the control reaches the mousePressed event alone. It doesn't reach the mouseReleased event.

    What I am doing is, if the mouse pressed point and mouse released point are not same, and if the selected text is not empty, will show the context menu.

  9. #109
    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
    Yes, if the pressed point and released point are not same, I will show the context menu at the released point.
    And if they are the same?

    Even from your example, I get only the mousePressed event.
    The point is that you do get it.

    I control doesnt reach the mouseReleased event itself. Only in mouseReleased, I am setting it to visible.
    If it is not the same item which accepted mousePressEvent, it will not get mouseReleaseEvent.

    Here the control reaches the mousePressed event alone. It doesn't reach the mouseReleased event.
    Last time you said it didn't reach mousePressed

    What I am doing is, if the mouse pressed point and mouse released point are not same, and if the selected text is not empty, will show the context menu.
    Why can't you do that from the HTML page like I suggested some number of posts earlier? It is much easier to get the presses there and then transmit that information to QtQuick so that it can 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.


  10. #110
    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
    And if they are the same?
    not gonna do anything with it unless, it's a link.

    Quote Originally Posted by wysota View Post
    The point is that you do get it.
    yes I get it

    Quote Originally Posted by wysota View Post
    If it is not the same item which accepted mousePressEvent, it will not get mouseReleaseEvent.
    didn't get you. here mousearea is the item which accepted mousePressEvent and same mousearea only accepting mouseReleaseEvent.
    I am getting confused
    Is it that when I say mouse.accepted = false in onPressed event, I wont get the control in onReleased event??

    Quote Originally Posted by wysota View Post
    Last time you said it didn't reach mousePressed
    my bad, I had given the print after the accepted = false.

    Quote Originally Posted by wysota View Post
    Why can't you do that from the HTML page like I suggested some number of posts earlier? It is much easier to get the presses there and then transmit that information to QtQuick so that it can show a context menu.
    The code is already there, as I have said many posts back, I am porting from QGraphicsWebView to WebEngineView.
    There are some thousand html pages already created.To change all the html pages, its difficult . May be for future ones can include.
    I have to make use of existing code of the app alone and can't make changes to existing html pages
    Last edited by ejoshva; 10th July 2015 at 13:13.

  11. #111
    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
    The code is already there, as I have said many posts back, I am porting from QGraphicsWebView to WebEngineView.
    There are some thousand html pages already created.To change all the html pages, its difficult .
    You don't have to do that. There is this nice "runJavaScript" method in WebEngineView which lets you execute arbitrary script any time you want.
    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.


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

    Default Re: How to set QWebEngineView on QQuickView

    so you mean to say that, after setting the mouse.accepted = false in onPressed event, I cant have some code executed in onReleased event ??

    even if I am executing javacript, when will I capture it? on the webengineview to bring up the contextmenu qml.


    can you please help to bring up in this flow only rather than bringing up a new one.
    Last edited by ejoshva; 11th July 2015 at 08:15.

  13. #113
    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
    so you mean to say that, after setting the mouse.accepted = false in onPressed event, I cant have some code executed in onReleased event ??
    It seems so. I think you could install an event filter on the element instead and intercept those events before they reach the webview without using a mouse area but that's much more complicated than what you are currently doing.

    even if I am executing javacript, when will I capture it? on the webengineview to bring up the contextmenu qml.
    The web component needs to have a mechanism (such as QWebChannel I mentioned earlier) that lets you communicate with Qt Quick. When you detect a press, a release and do your logic, simply tell Qt Quick to open the context menu.

    can you please help to bring up in this flow only rather than bringing up a new one.
    I don't understand what you mean.
    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.


Similar Threads

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