QML WebVIew and `runJavaScript()` with WinRT WebView
Unsolved
QML and Qt Quick
-
So I tried to run the following code on Windows 10 (Qt 5.13):
import QtQuick 2.13 import QtQuick.Window 2.13 import QtQuick.Controls 2.12 import QtWebView 1.1 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") WebView{ id: webView anchors{ top: button.bottom bottom: parent.bottom left: parent.left right: parent.right } url: "http://google.com" } Button{ id: button text: "Click me" onClicked: { console.debug("Running javascript") webView.runJavaScript("document.title", function(result) { console.log(result); }); } } }
When I click the button I get the following:
qt.winrtrunner.app: The WinRT WebView only supports calling global functions, so please make your call in the form myFunction(a, b, c). Also note that only string arguments can be passed.
What does that mean? Why isn't the console displaying the title of the website? Also could someone clarify for me what is the "callback" function in
WebView::runJavascript(script, variant callback)
?