您的位置:首页 > 移动开发 > Objective-C

QML中webview元素的javaScriptWindowObjects的使用示例

2012-10-09 09:59 1161 查看
示例来源于Qt自己的帮助文档(QML WebView):

 

This example shows how to call into a QML method using a window object.

这个例子显示的是如何使用window对象来调用qml中的方法:

WebView {
javaScriptWindowObjects: QtObject {
WebView.windowObjectName: "qml"

function qmlCall() {
console.log("This call is in QML!");
}
}

html: "<script>window.qml.qmlCall();</script>"
}

If Javascript is not enabled for the page, then this property does nothing.

当然能够使用js的前提是在webview中允许使用js,设置方法是:

settings.javascriptEnabled : bool

把这个属性设置成真!

 

 

 

 

 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息