summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/behaviours/test.qml2
-rw-r--r--examples/declarative/extending/binding/example.qml2
-rw-r--r--examples/declarative/extending/signal/example.qml2
-rw-r--r--examples/declarative/extending/valuesource/example.qml2
-rw-r--r--examples/declarative/focusscope/test.qml10
-rw-r--r--examples/declarative/focusscope/test3.qml4
-rw-r--r--examples/declarative/focusscope/test4.qml10
-rw-r--r--examples/declarative/mouseregion/mouse.qml24
-rw-r--r--examples/declarative/slideswitch/Switch.qml58
-rw-r--r--examples/declarative/slideswitch/content/Switch.qml73
-rw-r--r--examples/declarative/slideswitch/content/background.svg (renamed from examples/declarative/slideswitch/background.svg)0
-rw-r--r--examples/declarative/slideswitch/content/knob.svg (renamed from examples/declarative/slideswitch/knob.svg)0
-rw-r--r--examples/declarative/slideswitch/slideswitch.qml (renamed from examples/declarative/slideswitch/display.qml)5
-rw-r--r--examples/declarative/tabwidget/TabWidget.qml42
-rw-r--r--examples/declarative/tabwidget/tabs.qml29
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/samegame.qml2
-rw-r--r--examples/declarative/xmldata/daringfireball.qml2
-rw-r--r--examples/declarative/xmldata/yahoonews.qml2
-rw-r--r--examples/declarative/xmlhttprequest/test.qml18
19 files changed, 187 insertions, 100 deletions
diff --git a/examples/declarative/behaviours/test.qml b/examples/declarative/behaviours/test.qml
index 4a44fd7..1869c45 100644
--- a/examples/declarative/behaviours/test.qml
+++ b/examples/declarative/behaviours/test.qml
@@ -7,7 +7,7 @@ Rectangle {
id: page
MouseRegion {
anchors.fill: parent
- onClicked: { bluerect.parent = page; print(mouseX); bluerect.x = mouseX; }
+ onClicked: { bluerect.parent = page; console.log(mouseX); bluerect.x = mouseX; }
}
MyRect {
color: "green"
diff --git a/examples/declarative/extending/binding/example.qml b/examples/declarative/extending/binding/example.qml
index 352bb70..b66bc86 100644
--- a/examples/declarative/extending/binding/example.qml
+++ b/examples/declarative/extending/binding/example.qml
@@ -11,7 +11,7 @@ BirthdayParty {
shoe { size: 12; color: "white"; brand: "Nike"; price: 90.0 }
}
// ![0]
- onPartyStarted: print("This party started rockin' at " + time);
+ onPartyStarted: console.log("This party started rockin' at " + time);
Boy {
diff --git a/examples/declarative/extending/signal/example.qml b/examples/declarative/extending/signal/example.qml
index e46bf32..c7d4792 100644
--- a/examples/declarative/extending/signal/example.qml
+++ b/examples/declarative/extending/signal/example.qml
@@ -2,7 +2,7 @@ import People 1.0
// ![0]
BirthdayParty {
- onPartyStarted: print("This party started rockin' at " + time);
+ onPartyStarted: console.log("This party started rockin' at " + time);
// ![0]
celebrant: Boy {
diff --git a/examples/declarative/extending/valuesource/example.qml b/examples/declarative/extending/valuesource/example.qml
index 6d47350..7cdf8c0 100644
--- a/examples/declarative/extending/valuesource/example.qml
+++ b/examples/declarative/extending/valuesource/example.qml
@@ -5,7 +5,7 @@ BirthdayParty {
speaker: HappyBirthday { name: "Bob Jones" }
// ![0]
- onPartyStarted: print("This party started rockin' at " + time);
+ onPartyStarted: console.log("This party started rockin' at " + time);
celebrant: Boy {
diff --git a/examples/declarative/focusscope/test.qml b/examples/declarative/focusscope/test.qml
index ab5a143..e4332e7 100644
--- a/examples/declarative/focusscope/test.qml
+++ b/examples/declarative/focusscope/test.qml
@@ -5,13 +5,13 @@ Rectangle {
width: 800
height: 600
- Keys.onDigit9Pressed: print("Error - Root")
+ Keys.onDigit9Pressed: console.log("Error - Root")
FocusScope {
id: myScope
focus: true
- Keys.onDigit9Pressed: print("Error - FocusScope")
+ Keys.onDigit9Pressed: console.log("Error - FocusScope")
Rectangle {
height: 120
@@ -27,7 +27,7 @@ Rectangle {
width: 100; height: 100; color: "green"
border.width: 5
border.color: wantsFocus?"blue":"black"
- Keys.onDigit9Pressed: print("Top Left");
+ Keys.onDigit9Pressed: console.log("Top Left");
KeyNavigation.right: item2
focus: true
@@ -44,7 +44,7 @@ Rectangle {
border.width: 5
border.color: wantsFocus?"blue":"black"
KeyNavigation.left: item1
- Keys.onDigit9Pressed: print("Top Right");
+ Keys.onDigit9Pressed: console.log("Top Right");
Rectangle {
width: 50; height: 50; anchors.centerIn: parent
@@ -64,7 +64,7 @@ Rectangle {
border.width: 5
border.color: wantsFocus?"blue":"black"
- Keys.onDigit9Pressed: print("Bottom Left");
+ Keys.onDigit9Pressed: console.log("Bottom Left");
KeyNavigation.up: myScope
Rectangle {
diff --git a/examples/declarative/focusscope/test3.qml b/examples/declarative/focusscope/test3.qml
index 1b3181b..9344d07 100644
--- a/examples/declarative/focusscope/test3.qml
+++ b/examples/declarative/focusscope/test3.qml
@@ -23,10 +23,10 @@ Rectangle {
FocusScope {
id: root
width: 50; height: 50;
- Keys.onDigit9Pressed: print("Error - " + name)
+ Keys.onDigit9Pressed: console.log("Error - " + name)
Rectangle {
focus: true
- Keys.onDigit9Pressed: print(name)
+ Keys.onDigit9Pressed: console.log(name)
width: 50; height: 50;
color: root.ListView.isCurrentItem?"red":"green"
Text { text: name; anchors.centerIn: parent }
diff --git a/examples/declarative/focusscope/test4.qml b/examples/declarative/focusscope/test4.qml
index 5d4fe35..cc96df9 100644
--- a/examples/declarative/focusscope/test4.qml
+++ b/examples/declarative/focusscope/test4.qml
@@ -5,12 +5,12 @@ Rectangle {
width: 800
height: 600
- Keys.onDigit9Pressed: print("Error - Root")
+ Keys.onDigit9Pressed: console.log("Error - Root")
FocusScope {
id: myScope
- Keys.onDigit9Pressed: print("Error - FocusScope")
+ Keys.onDigit9Pressed: console.log("Error - FocusScope")
Rectangle {
height: 120
@@ -26,7 +26,7 @@ Rectangle {
width: 100; height: 100; color: "green"
border.width: 5
border.color: wantsFocus?"blue":"black"
- Keys.onDigit9Pressed: print("Error - Top Left");
+ Keys.onDigit9Pressed: console.log("Error - Top Left");
KeyNavigation.right: item2
focus: true
@@ -43,7 +43,7 @@ Rectangle {
border.width: 5
border.color: wantsFocus?"blue":"black"
KeyNavigation.left: item1
- Keys.onDigit9Pressed: print("Error - Top Right");
+ Keys.onDigit9Pressed: console.log("Error - Top Right");
Rectangle {
width: 50; height: 50; anchors.centerIn: parent
@@ -63,7 +63,7 @@ Rectangle {
border.width: 5
border.color: wantsFocus?"blue":"black"
- Keys.onDigit9Pressed: print("Error - Bottom Left");
+ Keys.onDigit9Pressed: console.log("Error - Bottom Left");
KeyNavigation.up: myScope
Rectangle {
diff --git a/examples/declarative/mouseregion/mouse.qml b/examples/declarative/mouseregion/mouse.qml
index 91f3b6e..d07d471 100644
--- a/examples/declarative/mouseregion/mouse.qml
+++ b/examples/declarative/mouseregion/mouse.qml
@@ -10,13 +10,13 @@ Rectangle {
MouseRegion {
hoverEnabled: true
acceptedButtons: Qt.LeftButton | Qt.RightButton
- onPressed: { print('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') }
- onReleased: { print('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') }
- onClicked: { print('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') }
- onDoubleClicked: { print('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')') }
- onPressAndHold: { print('press and hold') }
- onEntered: { print('entered ' + pressed) }
- onExited: { print('exited ' + pressed) }
+ onPressed: { console.log('press (x: ' + mouse.x + ' y: ' + mouse.y + ' button: ' + (mouse.button == Qt.RightButton ? 'right' : 'left') + ' Shift: ' + (mouse.modifiers & Qt.ShiftModifier ? 'true' : 'false') + ')') }
+ onReleased: { console.log('release (x: ' + mouse.x + ' y: ' + mouse.y + ' isClick: ' + mouse.isClick + ' wasHeld: ' + mouse.wasHeld + ')') }
+ onClicked: { console.log('click (x: ' + mouse.x + ' y: ' + mouse.y + ' wasHeld: ' + mouse.wasHeld + ')') }
+ onDoubleClicked: { console.log('double click (x: ' + mouse.x + ' y: ' + mouse.y + ')') }
+ onPressAndHold: { console.log('press and hold') }
+ onEntered: { console.log('entered ' + pressed) }
+ onExited: { console.log('exited ' + pressed) }
anchors.fill: parent
}
}
@@ -29,11 +29,11 @@ Rectangle {
drag.axis: "XAxis"
drag.minimumX: 0
drag.maximumX: 150
- onPressed: { print('press') }
- onReleased: { print('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')') }
- onClicked: { print('click' + '(wasHeld: ' + mouse.wasHeld + ')') }
- onDoubleClicked: { print('double click') }
- onPressAndHold: { print('press and hold') }
+ onPressed: { console.log('press') }
+ onReleased: { console.log('release (isClick: ' + mouse.isClick + ') (wasHeld: ' + mouse.wasHeld + ')') }
+ onClicked: { console.log('click' + '(wasHeld: ' + mouse.wasHeld + ')') }
+ onDoubleClicked: { console.log('double click') }
+ onPressAndHold: { console.log('press and hold') }
anchors.fill: parent
}
}
diff --git a/examples/declarative/slideswitch/Switch.qml b/examples/declarative/slideswitch/Switch.qml
deleted file mode 100644
index 4e13976..0000000
--- a/examples/declarative/slideswitch/Switch.qml
+++ /dev/null
@@ -1,58 +0,0 @@
-import Qt 4.6
-
-Item {
- id: mySwitch
- width: groove.width; height: groove.height
-
- property var on
-
- Script {
-
- function toggle() {
- if(mySwitch.state == "On")
- mySwitch.state = "Off";
- else
- mySwitch.state = "On";
- }
- function dorelease() {
- if(knob.x == 1) {
- if(mySwitch.state == "Off")
- return;
- }
-
- if(knob.x == 78) {
- if(mySwitch.state == "On")
- return;
- }
-
- toggle();
- }
-
- }
- Image { id: groove; source: "background.svg" }
- MouseRegion { anchors.fill: groove; onClicked: { toggle() } }
- Image { id: knob; source: "knob.svg"; x: 1; y: 2 }
- MouseRegion {
- anchors.fill: knob
- onClicked: { toggle() }
- onReleased: { dorelease() }
- drag.target: knob; drag.axis: "XAxis"; drag.minimumX: 1; drag.maximumX: 78
- }
- states: [
- State {
- name: "On"
- PropertyChanges { target: knob; x: 78 }
- PropertyChanges { target: mySwitch; on: true }
- },
- State {
- name: "Off"
- PropertyChanges { target: knob; x: 1 }
- PropertyChanges { target: mySwitch; on: false }
- }
- ]
- transitions: [
- Transition {
- NumberAnimation { matchProperties: "x"; easing: "easeInOutQuad"; duration: 200 }
- }
- ]
-}
diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml
new file mode 100644
index 0000000..29a62f7
--- /dev/null
+++ b/examples/declarative/slideswitch/content/Switch.qml
@@ -0,0 +1,73 @@
+//![0]
+import Qt 4.6
+
+Item {
+ id: toggleswitch
+ width: background.width; height: background.height
+
+//![1]
+ property bool on: false
+//![1]
+
+//![2]
+ function toggle() {
+ if (toggleswitch.state == "on")
+ toggleswitch.state = "off";
+ else toggleswitch.state = "on";
+ }
+//![2]
+
+//![3]
+ function dorelease() {
+ if (knob.x == 1) {
+ if (toggleswitch.state == "off") return;
+ }
+ if (knob.x == 78) {
+ if (toggleswitch.state == "on") return;
+ }
+ toggle();
+ }
+//![3]
+
+//![4]
+ Image {
+ id: background; source: "background.svg"
+ MouseRegion { anchors.fill: parent; onClicked: toggle() }
+ }
+//![4]
+
+//![5]
+ Image {
+ id: knob; source: "knob.svg"; x: 1; y: 2
+
+ MouseRegion {
+ anchors.fill: parent
+ drag.target: knob; drag.axis: "XAxis"; drag.minimumX: 1; drag.maximumX: 78
+ onClicked: toggle()
+ onReleased: dorelease()
+ }
+ }
+//![5]
+
+//![6]
+ states: [
+ State {
+ name: "on"
+ PropertyChanges { target: knob; x: 78 }
+ PropertyChanges { target: toggleswitch; on: true }
+ },
+ State {
+ name: "off"
+ PropertyChanges { target: knob; x: 1 }
+ PropertyChanges { target: toggleswitch; on: false }
+ }
+ ]
+//![6]
+
+//![7]
+ transitions: Transition {
+ NumberAnimation { matchProperties: "x"; easing: "easeInOutQuad"; duration: 200 }
+ }
+//![7]
+}
+//![0]
diff --git a/examples/declarative/slideswitch/background.svg b/examples/declarative/slideswitch/content/background.svg
index f920d3e..f920d3e 100644
--- a/examples/declarative/slideswitch/background.svg
+++ b/examples/declarative/slideswitch/content/background.svg
diff --git a/examples/declarative/slideswitch/knob.svg b/examples/declarative/slideswitch/content/knob.svg
index fb69337..fb69337 100644
--- a/examples/declarative/slideswitch/knob.svg
+++ b/examples/declarative/slideswitch/content/knob.svg
diff --git a/examples/declarative/slideswitch/display.qml b/examples/declarative/slideswitch/slideswitch.qml
index 346ffb1..9b46cd1 100644
--- a/examples/declarative/slideswitch/display.qml
+++ b/examples/declarative/slideswitch/slideswitch.qml
@@ -1,9 +1,10 @@
import Qt 4.6
+import "content"
Rectangle {
color: "white"
- width: 150
- height: 150
+ width: 400; height: 250
+
Switch {
anchors.centerIn: parent
}
diff --git a/examples/declarative/tabwidget/TabWidget.qml b/examples/declarative/tabwidget/TabWidget.qml
new file mode 100644
index 0000000..c56f41e
--- /dev/null
+++ b/examples/declarative/tabwidget/TabWidget.qml
@@ -0,0 +1,42 @@
+import Qt 4.6
+
+Item {
+ id: page
+ property int current: 0
+ default property alias content: stack.children
+ onCurrentChanged: setOpacities()
+ Component.onCompleted: setOpacities()
+ function setOpacities()
+ {
+ for (var i=0; i<stack.children.length; ++i) {
+ stack.children[i].opacity = i==current ? 1 : 0
+ }
+ }
+ Row {
+ id: header
+ Repeater {
+ delegate:
+ Rectangle {
+ width: page.width / stack.children.length
+ height: 15
+ color: page.current == index ? "grey" : "lightGrey"
+ Text {
+ anchors.fill: parent
+ text: stack.children[index].title
+ elide: Text.ElideRight
+ }
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: page.current = index
+ }
+ }
+ model: stack.children.length
+ }
+ }
+ Item {
+ id: stack
+ anchors.top: header.bottom
+ anchors.bottom: page.bottom
+ width: page.width
+ }
+}
diff --git a/examples/declarative/tabwidget/tabs.qml b/examples/declarative/tabwidget/tabs.qml
new file mode 100644
index 0000000..54ed7df
--- /dev/null
+++ b/examples/declarative/tabwidget/tabs.qml
@@ -0,0 +1,29 @@
+import Qt 4.6
+
+TabWidget {
+ id: tabs
+ width: 200
+ height: 200
+ current: 2
+ Rectangle {
+ property string title: "Red"
+ color: "red"
+ anchors.fill: parent
+ Text { anchors.centerIn: parent; text: "<div align=center>Roses are red"; font.pixelSize: 24
+ wrap: true; width: parent.width-20 }
+ }
+ Rectangle {
+ property string title: "Green"
+ color: "green"
+ anchors.fill: parent
+ Text { anchors.centerIn: parent; text: "<div align=center>Flower stems are green"; font.pixelSize: 24;
+ wrap: true; width: parent.width-20 }
+ }
+ Rectangle {
+ property string title: "Blue"
+ color: "blue"
+ anchors.fill: parent
+ Text { anchors.centerIn: parent; text: "<div align=center>Violets are blue"; color: "white"; font.pixelSize: 24
+ wrap: true; width: parent.width-20 }
+ }
+}
diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml
index 289579a..fad2175 100644
--- a/examples/declarative/tutorials/samegame/samegame1/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame1/samegame.qml
@@ -24,7 +24,7 @@ Rectangle {
anchors.bottom: Screen.bottom
Button {
- id: btnA; text: "New Game"; onClicked: print("Implement me!");
+ id: btnA; text: "New Game"; onClicked: console.log("Implement me!");
anchors.left: parent.left; anchors.leftMargin: 3
anchors.verticalCenter: parent.verticalCenter
}
diff --git a/examples/declarative/xmldata/daringfireball.qml b/examples/declarative/xmldata/daringfireball.qml
index 938bdd5..456f309 100644
--- a/examples/declarative/xmldata/daringfireball.qml
+++ b/examples/declarative/xmldata/daringfireball.qml
@@ -33,7 +33,7 @@ Rectangle {
text: content
anchors.top: titleText.bottom
width: 580; wrap: true
- onLinkActivated: { print('link clicked: ' + link) }
+ onLinkActivated: { console.log('link clicked: ' + link) }
}
}
}
diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml
index 4add361..bd14516 100644
--- a/examples/declarative/xmldata/yahoonews.qml
+++ b/examples/declarative/xmldata/yahoonews.qml
@@ -37,7 +37,7 @@ Rectangle {
x: 10; y: 5
text: '<a href=\'' + link + '\'>' + title + '</a>'
font.bold: true; font.family: "Helvetica"; font.pointSize: 14
- onLinkActivated: { print('link clicked: ' + link) }
+ onLinkActivated: { console.log('link clicked: ' + link) }
}
Text {
diff --git a/examples/declarative/xmlhttprequest/test.qml b/examples/declarative/xmlhttprequest/test.qml
index 18447e5..18e328b 100644
--- a/examples/declarative/xmlhttprequest/test.qml
+++ b/examples/declarative/xmlhttprequest/test.qml
@@ -10,21 +10,21 @@ Rectangle {
var doc = new XMLHttpRequest();
doc.onreadystatechange = function() {
if (doc.readyState == XMLHttpRequest.HEADERS_RECEIVED) {
- print ("Headers -->");
- print (doc.getAllResponseHeaders ());
- print ("Last modified -->");
- print (doc.getResponseHeader ("Last-Modified"));
+ console.log("Headers -->");
+ console.log(doc.getAllResponseHeaders ());
+ console.log("Last modified -->");
+ console.log(doc.getResponseHeader ("Last-Modified"));
}
else if (doc.readyState == XMLHttpRequest.DONE) {
var a = doc.responseXML.documentElement;
for (var ii = 0; ii < a.childNodes.length; ++ii) {
- print (a.childNodes[ii].nodeName);
+ console.log(a.childNodes[ii].nodeName);
}
- print ("Headers -->");
- print (doc.getAllResponseHeaders ());
- print ("Last modified -->");
- print (doc.getResponseHeader ("Last-Modified"));
+ console.log("Headers -->");
+ console.log(doc.getAllResponseHeaders ());
+ console.log("Last modified -->");
+ console.log(doc.getResponseHeader ("Last-Modified"));
}
}