Trigger javascript function from webview content
-
I'm using qt 5.3 with webkit 3 to load some html file in a webview element.
The file contains a javascript function that I would like to trigger from qml
I believe that evaluatejavascript was used for these kind of actions in previous versions of webkit.
The qml file:
@
import QtQuick 2.0
import QtWebKit 3.0Rectangle {
id: rootObject
objectName: "rootObject"
width: 360
height: 360WebView { id: myWebView anchors.top: topBar.bottom anchors.topMargin: 40 anchors.fill: parent url: "file:///C:/svnwork/Highstock/index.htm" } MouseArea { id: button onClicked: myWebView.writeText('some text') }
}
@The html file:
@
<div id="container"></div><javascript>
function writeText(text){
document.getElementById('container').value = text;
}
</javascript>
@How can I trigger the writeText function in qml?
-
Hi,
Can you check this "link":http://rschroll.github.io/beru/2013/08/21/qtwebview.experimental.html ? It seems for now you need to use experimental stuff.
-
Hi,
Can you check this "link":http://rschroll.github.io/beru/2013/08/21/qtwebview.experimental.html ? It seems for now you need to use experimental stuff.