Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MyWebView.qml
- Rectangle {
- id: rectMyWebView
- width: 1000
- height: 800
- WebView {
- id: myWebView
- objectName: "webView"
- anchors.fill: parent
- url: "file:///d:\test.html"
- function fromHtmlToQML1(text)
- {
- console.log("Text from html" + text)
- }
- }
- // Called from Qt code: OK!!
- function fromQtToQml(text)
- {
- console.log("Text from qt: " + text)
- runJavaScript("jsCall2", function(result) { console.log(result); });
- }
- // 2nd option
- function fromHtmlToQML2(text)
- {
- console.log("Text from html" + text)
- }
- }
- <!doctype html>
- <html>
- <head>
- <style type="text/css">
- ...
- ...
- </style>
- </head>
- <body>
- ...
- <script src="test.js" type="text/javascript"></script>
- <div class="mybutton"> <button onclick='myFunction1()'>Call Qt</button></div>
- ...
- </body>
- </html>
- function myFunction1() {
- myWebView.fromHtmlToQML1();
- myWebView.fromHtmlToQML2();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement