qt4 qmlでは、qtwebkit1.0のコンポーネントwebviewにプロパティがありますjavaScriptWindowObjects
。これを使用して、WebページのJavaScriptのコンテキストにjavaScriptWindowObjectsを追加し、c++関数を呼び出しました。そのようです
WebView{
url: "http://test.com"
anchors.fill: parent
scale: 1.0
javaScriptWindowObjects: QtObject {
WebView.windowObjectName: "native"
function foo(x, y) {
console.log("This is a call from javascript");
myCppHandler.fooNative(b,c);
}
}
}
だから私はそのようにウェブページのJavaScriptからそれを呼び出すことができます
<script type="text/javascript">
native.foo(1,2)
</script>
しかし、qt5 qml qtwebkit 3.0には、そのようなものはありません。javaScriptWindowObjects
qt5 qmlでそれをどのように達成できますか?