Details
Description
When using runJavaScript, the iOS version cannot return an object, while Android and OSX can.
import QtQuick 2.11 import QtQuick.Window 2.11 import QtWebView 1.1 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") property string html: "<html><script>var testResult={key: 'I exist!'};</script><body><canvas></canvas></body></html>"; Component.onCompleted: { webview.loadHtml(html, ''); } Timer { id: testTimer interval: 1000 repeat:false running: false onTriggered: { webview.runJavaScript("try {testResult} catch (e) {'undefined'}", function (result) { console.log('object', JSON.stringify(result)); }); webview.runJavaScript("try {JSON.stringify(testResult)} catch (e) {'undefined'}", function (result) { console.log('stringified', JSON.stringify(result)); }); } onRunningChanged: console.log('running', running); } WebView { id: webview anchors.fill: parent onLoadProgressChanged: { console.log('loadProgress', loadProgress) if (loadProgress == 100) testTimer.running = true; } } }
Attachments
For Gerrit Dashboard: QTBUG-70166 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
582724,4 | Add support for NSArray and NSDictionary in Darwin WebView's fromJSValue | dev | qt/qtwebview | Status: MERGED | +2 | 0 |
583441,2 | Add support for NSArray and NSDictionary in Darwin WebView's fromJSValue | 6.8 | qt/qtwebview | Status: MERGED | +2 | 0 |
583752,2 | Add support for NSArray and NSDictionary in Darwin WebView's fromJSValue | 6.7 | qt/qtwebview | Status: MERGED | +2 | 0 |
583968,2 | Add support for NSArray and NSDictionary in Darwin WebView's fromJSValue | tqtc/lts-6.5 | qt/tqtc-qtwebview | Status: MERGED | +2 | 0 |