Advertisement
Guest User

Untitled

a guest
May 26th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. MyWebView.qml
  2.  
  3. Rectangle {
  4. id: rectMyWebView
  5.  
  6. width: 1000
  7. height: 800
  8.  
  9. WebView {
  10. id: myWebView
  11.  
  12. objectName: "webView"
  13.  
  14. anchors.fill: parent
  15. url: "file:///d:\test.html"
  16.  
  17. function fromHtmlToQML1(text)
  18. {
  19. console.log("Text from html" + text)
  20. }
  21. }
  22.  
  23. // Called from Qt code: OK!!
  24. function fromQtToQml(text)
  25. {
  26. console.log("Text from qt: " + text)
  27. runJavaScript("jsCall2", function(result) { console.log(result); });
  28. }
  29.  
  30. // 2nd option
  31.  
  32. function fromHtmlToQML2(text)
  33. {
  34. console.log("Text from html" + text)
  35. }
  36. }
  37.  
  38. <!doctype html>
  39. <html>
  40. <head>
  41. <style type="text/css">
  42. ...
  43. ...
  44. </style>
  45. </head>
  46.  
  47. <body>
  48. ...
  49.  
  50. <script src="test.js" type="text/javascript"></script>
  51.  
  52. <div class="mybutton"> <button onclick='myFunction1()'>Call Qt</button></div>
  53.  
  54. ...
  55.  
  56. </body>
  57. </html>
  58.  
  59. function myFunction1() {
  60. myWebView.fromHtmlToQML1();
  61. myWebView.fromHtmlToQML2();
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement