Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QML WebVIew and `runJavaScript()` with WinRT WebView

QML WebVIew and `runJavaScript()` with WinRT WebView

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
windows 10winrtwebviewqml
1 Posts 1 Posters 749 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    daljit97
    wrote on last edited by
    #1

    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)?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved