Page 5 of 6 FirstFirst ... 3456 LastLast
Results 81 to 100 of 113

Thread: How to set QWebEngineView on QQuickView

  1. #81
    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

    That's not what anda_skoa had in mind. You were supposed to set "accepted" property of the event object to false.

    javascript Code:
    1. onPressed: { mouse.accepted = false }
    To copy to clipboard, switch view to plain text mode 
    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. #82
    Join Date
    Feb 2015
    Posts
    185
    Thanks
    5
    Qt products
    Qt5
    Platforms
    MacOS X Windows

    Default Re: How to set QWebEngineView on QQuickView

    after including this code, the mousearea itself is not enabled.

    Please let me know, how to capture enable text selection through MouseArea and this MouseArea to be always enabled.

  3. #83
    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

    text selection is done by the web view element, not by the mouse area.
    the idea was to pass the events through to the view for its selection handling.

    Cheers,
    _

  4. #84
    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
    text selection is done by the web view element, not by the mouse area.
    the idea was to pass the events through to the view for its selection handling.

    Cheers,
    _
    In that case, the control doesn't reach the mousearea when I include the mouse.accept = false.

    if it's handled by the webview element, on which signal of the webview element I can catch the selection

  5. #85
    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, the control doesn't reach the mousearea when I include the mouse.accept = false.
    You mean this doesn't work?

    javascript Code:
    1. WebEngineView {
    2. anchors.fill: parent
    3.  
    4. MouseArea {
    5. anchors.fill: parent
    6.  
    7. onClicked: {
    8. console.log("I was clicked at "+mouse.x+"x"+mouse.y)
    9. mouse.accepted = false
    10. }
    11. }
    12. }
    To copy to clipboard, switch view to plain text mode 

    if it's handled by the webview element, on which signal of the webview element I can catch the selection
    WebEngineView does not have such signal, I think I already said so a couple of posts ago.
    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.


  6. #86
    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. //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.  
    13. drag {
    14. target: currentWebview
    15. axis : "XAndYAxis"
    16. active: true
    17. }
    18.  
    19. onPressed: {
    20. pressPoint.x = mouseX
    21. pressPoint.y = mouseY
    22. console.log("PressPoint : "+pressPoint)
    23.  
    24. }
    25. onReleased: {
    26. releasePoint.x = mouseX
    27. releasePoint.y = mouseY
    28. console.log("releasePoint : "+releasePoint)
    29. if(pressPoint != releasePoint )
    30. {
    31. mouse.accepted = false
    32. currentWebview.runJavaScript("window.getSelection()", function(result) { console.log("selected Text=" + result);} )
    33. }
    34. }
    35.  
    36. }
    37. }
    To copy to clipboard, switch view to plain text mode 

    The code is as above and logs got are
    qml: PressPoint : QPointF(513, 101)
    qml: releasePoint : QPointF(716, 99)
    qml: selected Text=[object Object]



    the selected text is just object because text selection was disabled.

    how do I get the text there.

  7. #87
    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
    javascript Code:
    1. drag {
    2. target: currentWebview
    3. axis : "XAndYAxis"
    4. active: true
    5. }
    To copy to clipboard, switch view to plain text mode 
    Why do you insist on keeping this code? It doesn't do what you think it does.

    the selected text is just object because text selection was disabled.
    The selected text is an object because everything in JavaScript is an object.

    https://developer.mozilla.org/en-US/...w/getSelection
    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. #88
    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
    In that case, the control doesn't reach the mousearea when I include the mouse.accept = false.
    Which of the events do you get and do not accept and which ones do you not get at all?

    Cheers,
    _

  9. #89
    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 of the events do you get and do not accept and which ones do you not get at all?

    Cheers,
    _
    none of the events defined in mousearea was caught when selection is enabled.

    When selection is disabled, all the events of the mousearea are got

  10. #90
    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

    Please show the exact code you used for testing this.

    This works for me without problems:

    javascript Code:
    1. import QtWebEngine 1.0
    2. import QtQuick 2.4
    3.  
    4.  
    5. WebEngineView {
    6. url: "http://www.google.com"
    7.  
    8. MouseArea {
    9. anchors.fill: parent
    10.  
    11. onPressed: {
    12. console.log("Pressed: "+mouse.x+"x"+mouse.y)
    13. mouse.accepted = false
    14. }
    15.  
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 8th July 2015 at 10:25.
    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. #91
    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
    Why do you insist on keeping this code? It doesn't do what you think it does.


    The selected text is an object because everything in JavaScript is an object.

    https://developer.mozilla.org/en-US/...w/getSelection
    thanks for pointing it out Wysota.
    Will remove that code.

    Now I am not able to select any text. Just that I drag it over the text area.


    Added after 33 minutes:


    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.  
    13. onPressed: {
    14. pressPoint.x = mouseX
    15. pressPoint.y = mouseY
    16. console.log("PressPoint : "+pressPoint)
    17.  
    18. }
    19. onReleased: {
    20. releasePoint.x = mouseX
    21. releasePoint.y = mouseY
    22. console.log("releasePoint : "+releasePoint)
    23. if(pressPoint != releasePoint )
    24. {
    25. mouse.accepted = false
    26. currentWebview.runJavaScript("window.getSelection()", function(result) { console.log("selected Text =" + result.toString());} )
    27. }
    28. }
    29.  
    30. }
    31. }
    To copy to clipboard, switch view to plain text mode 

    This is the code used for testing that.

    Now I get the signals onPressed, onReleased in the mousearea.


    but the text selection is unavailable. Just that I can drag the mouse.
    Last edited by ejoshva; 8th July 2015 at 10:52.

  12. #92
    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
    Now I get the signals onPressed, onReleased in the mousearea.


    but the text selection is unavailable. Just that I can drag the mouse.
    What if you do not accept the events?

    Cheers,
    _

  13. #93
    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
    Now I get the signals onPressed, onReleased in the mousearea.


    but the text selection is unavailable. Just that I can drag the mouse.
    You are not ignoring the events. Only an ignored event will be propagated to an item below the mouse area. This is all in the docs, please read it instead of wasting your time for meaningless problems.
    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.


  14. #94
    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 if you do not accept the events?

    Cheers,
    _
    I am not able to find any difference.

    the problem I face here is that the text selection is not available. I don't find the cursor itself, just the mouse pointer which means only clicks are allowed and selection is not allowed.

    Yes, there has been quite a few posts about me stating selection not available . But I am not able to understand what you are trying to convery


    Added after 4 minutes:


    Quote Originally Posted by wysota View Post
    You are not ignoring the events. Only an ignored event will be propagated to an item below the mouse area. This is all in the docs, please read it instead of wasting your time for meaningless problems.
    All I need here is the text selection, can you please tell me. how do I do that. There has quite a few posts, you stating it's handled by WebEngineView itself. But after implementing MouseArea, there is only mouse pointer and not cursor that means only clicks are allowed and not selection. can you please tell me how to make text selection available.
    Last edited by ejoshva; 9th July 2015 at 05:41.

  15. #95
    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
    All I need here is the text selection, can you please tell me. how do I do that.
    I already told you, I even gave you a working example (post #90) which you silently ignored and another one earlier (#85) which you didn't comment as well.

    can you please tell me how to make text selection available.
    Don't do anything. It works by default. However I think you want something else -- you want a mouse area over an item and still have items reach the webview. For that, as said many times already, events need to be ignored (accepted = false) in the mouse area. Nobody will do that for you -- you have to decide yourself which events to consume in the mouse area and which to pass to the underlying item.

    Wow... we are going to reach 100 posts in this thread...
    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.


  16. #96
    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
    I already told you, I even gave you a working example (post #90) which you silently ignored and another one earlier (#85) which you didn't comment as well.
    I didn't intend to ignore you post.
    For the post#90, I replied with the code which you asked for.
    Also post #85 I have included.

    Below is the current code and have also attached the screen of what I trying to do.
    Qt Code:
    1. //ContextMenu.qml
    2. import QtQuick 2.0
    3.  
    4. Rectangle {
    5. id : cxtMenu
    6. width: 140
    7. height: 24
    8. radius: width*0.5
    9. color: "#222222"
    10. Image {
    11. id: triangle
    12. height: 15
    13. width: 15
    14. anchors.top: parent.top
    15. anchors.topMargin: 24
    16. anchors.horizontalCenter: parent.horizontalCenter
    17. smooth: true
    18. source: "qrc:/images/triangle.png"
    19. visible: true
    20. }
    21. Rectangle {
    22. id:hglt
    23. height: 24
    24. width: 60
    25. radius: width*0.1
    26. anchors.top : parent.top
    27. anchors.left: parent.left
    28. border.color: "#000000"
    29. border.width: 0
    30. color: "#222222"
    31.  
    32. Text {
    33. id:hglttext
    34. text: qsTr("Highlight")
    35. font.pointSize: 11
    36. font.family: "san-serif"
    37. anchors.left: parent.left
    38. anchors.leftMargin: 10
    39. anchors.top: parent.top
    40. anchors.topMargin: 5
    41. smooth: true
    42. color: "#CFCFCF"
    43. MouseArea {
    44. anchors.fill: parent
    45. onClicked: {
    46. browserwindow.cxtMenu()
    47. }
    48. }
    49. }
    50. }
    51. Rectangle {
    52. id:verticalline
    53. height: parent.height
    54. width: 1
    55. anchors.top :parent.top
    56. anchors.left: parent.left
    57. anchors.leftMargin: 70
    58. color: "#CFCFCF"
    59. }
    60.  
    61. Rectangle {
    62. id:annot
    63. height: 24
    64. width: 80
    65. radius: width*0.1
    66. anchors.top : parent.top
    67. anchors.left: parent.left
    68. anchors.leftMargin: 71
    69. border.color: "#000000"
    70. border.width: 0
    71. color: "#222222"
    72.  
    73. Text {
    74. id:annottext
    75. text: qsTr("Annotation")
    76. font.pointSize: 11
    77. font.family: "san-serif"
    78. anchors.left: parent.left
    79. anchors.leftMargin: 10
    80. anchors.top: parent.top
    81. anchors.topMargin: 5
    82. smooth: true
    83. color: "#CFCFCF"
    84. MouseArea {
    85. anchors.fill: parent
    86. onClicked: {
    87. browserwindow.newnotes()
    88. }
    89. }
    90. }
    91. }
    92. }
    93.  
    94.  
    95. //BrowserWindow.qml
    96. import QtQuick 2.0
    97. import QtQuick.Controls 1.3
    98. import QtWebEngine 1.0
    99.  
    100.  
    101. Rectangle {
    102. id:flick
    103. height: parent.height
    104. width: parent.width - 5
    105. property variant mypoint: Qt.point(10,10)
    106. property variant pressPoint: Qt.point(10,10)
    107. property variant releasePoint: Qt.point(10,10)
    108. property string pagecontents: ""
    109. property string url: ""
    110. WebEngineView {
    111. id: currentWebview
    112. objectName: "webView"
    113. //url: "http://www.google.co.in"
    114. anchors.fill: parent
    115. readonly property string htmlContent: content
    116. onHtmlContentChanged: loadHtml(htmlContent, baseUrl);
    117.  
    118. MouseArea {
    119. id : mousearea
    120. anchors.fill: parent
    121.  
    122. onPressed: {
    123. pressPoint.x = mouseX
    124. pressPoint.y = mouseY
    125. console.log("PressPoint : "+pressPoint)
    126.  
    127. }
    128. onReleased: {
    129. releasePoint.x = mouseX
    130. releasePoint.y = mouseY
    131. console.log("releasePoint : "+releasePoint)
    132. if(pressPoint != releasePoint )
    133. {
    134. mouse.accepted = false
    135. currentWebview.runJavaScript("window.getSelection()", function(result) { console.log("selected Text =" + result.toString());} )
    136. cntxtMenu.visible = true
    137. cntxtMenu.x = mouseX - 80
    138. cntxtMenu.y = mouseY - 38
    139. }
    140. }
    141.  
    142. }
    143. }
    144. }
    To copy to clipboard, switch view to plain text mode 
    Screen Shot 2015-07-09 at 11.45.18 AM.jpg
    What I am trying to do is. on mouse release will bring in a context menu to highlight the selected text or add annotation to selected text
    Quote Originally Posted by wysota View Post
    Don't do anything. It works by default. However I think you want something else -- you want a mouse area over an item and still have items reach the webview. For that, as said many times already, events need to be ignored (accepted = false) in the mouse area. Nobody will do that for you -- you have to decide yourself which events to consume in the mouse area and which to pass to the underlying item
    Yes, without including the mousearea selection was available. After including the mousearea only selection is unavailable.
    I am confused to choose which event needs to be ignored to make the text selection available.

    Quote Originally Posted by wysota View Post
    Wow... we are going to reach 100 posts in this thread...
    Thx Wysota and anda_skoa for your continuous guidance and help. Without you both, I wouldn't have been able to reach where I am now. Thanks a ton.
    Hope, I would be able to complete what I am trying with your help.

  17. #97
    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
    Below is the current code and have also attached the screen of what I trying to do.
    Qt Code:
    1. onPressed: {
    2. pressPoint.x = mouseX
    3. pressPoint.y = mouseY
    4. console.log("PressPoint : "+pressPoint)
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 
    Can you point out in which of these lines you are calling mouse.accept = false?

    I keep looking at the code and can't find it. Is it in some invisible font in the line after console.log?

    Cheers,
    _

  18. #98
    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 anda_skoa View Post
    Can you point out in which of these lines you are calling mouse.accept = false?

    I keep looking at the code and can't find it. Is it in some invisible font in the line after console.log?
    I was meaning to ask the same thing.
    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.


  19. #99
    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
    I was meaning to ask the same thing.
    I have included in OnReleased
    Qt Code:
    1. onReleased: {
    2. releasePoint.x = mouseX
    3. releasePoint.y = mouseY
    4. console.log("releasePoint : "+releasePoint)
    5. if(pressPoint != releasePoint )
    6. {
    7. [B] mouse.accepted = false[/B]
    8. currentWebview.runJavaScript("window.getSelection()", function(result) { console.log("selected Text =" + result.toString());} )
    9. cntxtMenu.visible = true
    10. cntxtMenu.x = mouseX - 80
    11. cntxtMenu.y = mouseY - 38
    12. }
    13. }
    To copy to clipboard, switch view to plain text mode 

    I understood as only I am doing something customised alone I will have to include mouse.accepted = false. In mousePressed, I am not doing anything customised, just storing the value.,

  20. #100
    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

    Well, if you don't pass the press event to the web view, how is the web view supposed to start drag selection?

    Cheers,
    _

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.