summaryrefslogtreecommitdiffstats
path: root/examples/declarative/webview/evalandattach.qml
blob: 1b211c9d861a61a3a4c02b5fc4590fa3aa7dcfd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import Qt 4.6

Item {
    height: 640
    width: 360
    Text {
        id: teksti
        text: webView.statusText1
        anchors.top: parent.top
        height: 30
        anchors.left: parent.left
        width: parent.width/2
    }

    Text {
        id: teksti2
        text: webView.statusText2
        anchors.top: parent.top
        height: 30
        anchors.left: teksti.right
        anchors.right: parent.right
    }

    MouseRegion {
        anchors.fill: teksti
        onClicked: { webView.evaluateJavaScript ("do_it()") }
    }

    WebView {
        id: webView
        property alias statusText1: txt.text
        property alias statusText2: txt2.text
        anchors.top: teksti.bottom
        anchors.bottom: parent.bottom
        anchors.left: parent.left
        anchors.right: parent.right
        focus: true
        settings.pluginsEnabled: true
        javaScriptWindowObjects: [
        QtObject {
            id: txt
            WebView.windowObjectName: "statusText1"
            property string text: "Click me!"
        },
        QtObject {
            id: txt2
            WebView.windowObjectName: "statusText2"
            property string text: ""
        }
        ]
        url: "evalandattach.html"
    }

}