diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-03-31 01:47:33 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-03-31 01:47:33 (GMT) |
commit | f31145a524f1d0098fb1c523e288359e023e926b (patch) | |
tree | e0a607ca1c7ba543c194051d8c439ace25bcf9d6 | |
parent | 07f6fe57bf15ac06a6e0672abd1fa4acdc61548e (diff) | |
download | Qt-f31145a524f1d0098fb1c523e288359e023e926b.zip Qt-f31145a524f1d0098fb1c523e288359e023e926b.tar.gz Qt-f31145a524f1d0098fb1c523e288359e023e926b.tar.bz2 |
example of WebView onAlert, and of popups in general.
-rw-r--r-- | examples/declarative/webview/alerts.html | 5 | ||||
-rw-r--r-- | examples/declarative/webview/alerts.qml | 58 |
2 files changed, 63 insertions, 0 deletions
diff --git a/examples/declarative/webview/alerts.html b/examples/declarative/webview/alerts.html new file mode 100644 index 0000000..82caddf --- /dev/null +++ b/examples/declarative/webview/alerts.html @@ -0,0 +1,5 @@ +<html> +<body onclick="alert('This is an alert')"> +<p>This is a web page. It fires an alert when clicked. +</body> +</html> diff --git a/examples/declarative/webview/alerts.qml b/examples/declarative/webview/alerts.qml new file mode 100644 index 0000000..ab2e860 --- /dev/null +++ b/examples/declarative/webview/alerts.qml @@ -0,0 +1,58 @@ +import Qt 4.6 +import org.webkit 1.0 + +WebView { + id: webView + onAlert: popup.show(message) + width: 120 + height: 150 + url: "alerts.html" + + Rectangle { + id: popup + + color: "red" + border.color: "black" + border.width: 2 + radius: 4 + + y: parent.height // off "screen" + anchors.horizontalCenter: parent.horizontalCenter + width: label.width+5 + height: label.height+5 + + opacity: 0 + + function show(t) { + label.text = t + popup.state = "visible" + timer.start() + } + states: State { + name: "visible" + PropertyChanges { target: popup; opacity: 1 } + PropertyChanges { target: popup; y: (webView.height-popup.height)/2 } + } + + transitions: [ + Transition { from: ""; PropertyAnimation { properties: "opacity,y"; duration: 65 } }, + Transition { from: "visible"; PropertyAnimation { properties: "opacity,y"; duration: 500 } } + ] + + Timer { + id: timer + interval: 1000 + onTriggered: popup.state = "" + } + + Text { + id: label + anchors.centerIn: parent + color: "white" + font.pixelSize: 20 + width: webView.width*0.75 + wrap: true + horizontalAlignment: "AlignHCenter" + } + } +} |