summaryrefslogtreecommitdiffstats
path: root/examples/declarative/tutorials
diff options
context:
space:
mode:
Diffstat (limited to 'examples/declarative/tutorials')
-rw-r--r--examples/declarative/tutorials/helloworld/Cell.qml6
-rw-r--r--examples/declarative/tutorials/helloworld/tutorial2.qml14
-rw-r--r--examples/declarative/tutorials/helloworld/tutorial3.qml19
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/Button.qml4
-rw-r--r--examples/declarative/tutorials/samegame/samegame1/samegame.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/Button.qml4
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/samegame.js6
-rw-r--r--examples/declarative/tutorials/samegame/samegame2/samegame.qml8
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Button.qml4
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/Dialog.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/samegame.js6
-rw-r--r--examples/declarative/tutorials/samegame/samegame3/samegame.qml7
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/Button.qml4
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml2
-rw-r--r--examples/declarative/tutorials/samegame/samegame4/samegame.qml11
16 files changed, 50 insertions, 51 deletions
diff --git a/examples/declarative/tutorials/helloworld/Cell.qml b/examples/declarative/tutorials/helloworld/Cell.qml
index de4f3bb..9249ffe 100644
--- a/examples/declarative/tutorials/helloworld/Cell.qml
+++ b/examples/declarative/tutorials/helloworld/Cell.qml
@@ -5,10 +5,10 @@ import Qt 4.6
Item {
id: container
//![4]
- property alias color: rectangle.color
+ property alias cellColor: rectangle.color
//![4]
//![5]
- signal clicked(color color)
+ signal clicked(color cellColor)
//![5]
width: 40; height: 25
@@ -25,7 +25,7 @@ Item {
//![3]
MouseArea {
anchors.fill: parent
- onClicked: container.clicked(container.color)
+ onClicked: container.clicked(container.cellColor)
}
//![3]
}
diff --git a/examples/declarative/tutorials/helloworld/tutorial2.qml b/examples/declarative/tutorials/helloworld/tutorial2.qml
index 99889d7..38447e2 100644
--- a/examples/declarative/tutorials/helloworld/tutorial2.qml
+++ b/examples/declarative/tutorials/helloworld/tutorial2.qml
@@ -15,17 +15,17 @@ Rectangle {
Grid {
id: colorPicker
- anchors.bottom: page.bottom
+ x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4
rows: 2; columns: 3; spacing: 3
//![1]
- Cell { color: "red"; onClicked: helloText.color = color }
+ Cell { cellColor: "red"; onClicked: helloText.color = cellColor }
//![1]
- Cell { color: "green"; onClicked: helloText.color = color }
- Cell { color: "blue"; onClicked: helloText.color = color }
- Cell { color: "yellow"; onClicked: helloText.color = color }
- Cell { color: "steelblue"; onClicked: helloText.color = color }
- Cell { color: "black"; onClicked: helloText.color = color }
+ Cell { cellColor: "green"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "blue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "black"; onClicked: helloText.color = cellColor }
}
}
//![0]
diff --git a/examples/declarative/tutorials/helloworld/tutorial3.qml b/examples/declarative/tutorials/helloworld/tutorial3.qml
index b8a4f77..d851c49 100644
--- a/examples/declarative/tutorials/helloworld/tutorial3.qml
+++ b/examples/declarative/tutorials/helloworld/tutorial3.qml
@@ -11,15 +11,14 @@ Rectangle {
text: "Hello world!"
font.pointSize: 24; font.bold: true
y: 30; anchors.horizontalCenter: page.horizontalCenter
- transformOrigin: Item.Center
//![1]
- MouseArea { id: mouseRegion; anchors.fill: parent }
+ MouseArea { id: mouseArea; anchors.fill: parent }
//![1]
//![2]
states: State {
- name: "down"; when: mouseRegion.pressed == true
+ name: "down"; when: mouseArea.pressed == true
PropertyChanges { target: helloText; y: 160; rotation: 180; color: "red" }
}
//![2]
@@ -37,15 +36,15 @@ Rectangle {
Grid {
id: colorPicker
- anchors.bottom: page.bottom
+ x: 4; anchors.bottom: page.bottom; anchors.bottomMargin: 4
rows: 2; columns: 3; spacing: 3
- Cell { color: "red"; onClicked: helloText.color = color }
- Cell { color: "green"; onClicked: helloText.color = color }
- Cell { color: "blue"; onClicked: helloText.color = color }
- Cell { color: "yellow"; onClicked: helloText.color = color }
- Cell { color: "steelblue"; onClicked: helloText.color = color }
- Cell { color: "black"; onClicked: helloText.color = color }
+ Cell { cellColor: "red"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "green"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "blue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "yellow"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "steelblue"; onClicked: helloText.color = cellColor }
+ Cell { cellColor: "black"; onClicked: helloText.color = cellColor }
}
}
//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame1/Button.qml b/examples/declarative/tutorials/samegame/samegame1/Button.qml
index 2e31ff8..5e28da7 100644
--- a/examples/declarative/tutorials/samegame/samegame1/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame1/Button.qml
@@ -14,11 +14,11 @@ Rectangle {
gradient: Gradient {
GradientStop {
id: topGrad; position: 0.0
- color: if (mr.pressed) { activePalette.dark } else { activePalette.light } }
+ color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } }
GradientStop { position: 1.0; color: activePalette.button }
}
- MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+ MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
Text {
id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
diff --git a/examples/declarative/tutorials/samegame/samegame1/samegame.qml b/examples/declarative/tutorials/samegame/samegame1/samegame.qml
index 5ed30c9..006b926 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: console.log("Implement me!");
+ id: btnA; text: "New Game"; onClicked: console.log("Starting a new game...");
anchors.left: parent.left; anchors.leftMargin: 3
anchors.verticalCenter: parent.verticalCenter
}
diff --git a/examples/declarative/tutorials/samegame/samegame2/Button.qml b/examples/declarative/tutorials/samegame/samegame2/Button.qml
index 6629302..a7853d4 100644
--- a/examples/declarative/tutorials/samegame/samegame2/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame2/Button.qml
@@ -13,11 +13,11 @@ Rectangle {
gradient: Gradient {
GradientStop {
id: topGrad; position: 0.0
- color: if (mr.pressed) { activePalette.dark } else { activePalette.light } }
+ color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } }
GradientStop { position: 1.0; color: activePalette.button }
}
- MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+ MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
Text {
id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.js b/examples/declarative/tutorials/samegame/samegame2/samegame.js
index 2c02c61..0ec3a8b 100644
--- a/examples/declarative/tutorials/samegame/samegame2/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame2/samegame.js
@@ -15,6 +15,12 @@ function index(xIdx,yIdx) {
function initBoard()
{
+ //Delete old blocks
+ for(var i = 0; i<maxIndex; i++){
+ if(board[i] != null)
+ board[i].destroy();
+ }
+
//Calculate board size
maxX = Math.floor(background.width/tileSize);
maxY = Math.floor(background.height/tileSize);
diff --git a/examples/declarative/tutorials/samegame/samegame2/samegame.qml b/examples/declarative/tutorials/samegame/samegame2/samegame.qml
index 7e0bc0c..89d8035 100644
--- a/examples/declarative/tutorials/samegame/samegame2/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame2/samegame.qml
@@ -1,13 +1,13 @@
import Qt 4.6
+//![2]
+import "samegame.js" as SameGame
+//![2]
Rectangle {
id: screen
width: 490; height: 720
SystemPalette { id: activePalette }
-//![2]
- Script { source: "samegame.js" }
-//![2]
Item {
width: parent.width; anchors.top: parent.top; anchors.bottom: toolbar.top
@@ -27,7 +27,7 @@ Rectangle {
//![1]
Button {
- id: btnA; text: "New Game"; onClicked: initBoard();
+ id: btnA; text: "New Game"; onClicked: SameGame.initBoard();
anchors.left: parent.left; anchors.leftMargin: 3
anchors.verticalCenter: parent.verticalCenter
}
diff --git a/examples/declarative/tutorials/samegame/samegame3/Button.qml b/examples/declarative/tutorials/samegame/samegame3/Button.qml
index 6629302..a7853d4 100644
--- a/examples/declarative/tutorials/samegame/samegame3/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/Button.qml
@@ -13,11 +13,11 @@ Rectangle {
gradient: Gradient {
GradientStop {
id: topGrad; position: 0.0
- color: if (mr.pressed) { activePalette.dark } else { activePalette.light } }
+ color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } }
GradientStop { position: 1.0; color: activePalette.button }
}
- MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+ MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
Text {
id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
diff --git a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
index 36178ec..966f85a 100644
--- a/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/Dialog.qml
@@ -18,6 +18,6 @@ Rectangle {
NumberAnimation { duration: 1000 }
}
Text { id: myText; anchors.centerIn: parent; text: "Hello World!" }
- MouseArea { id: mr; anchors.fill: parent; onClicked: forceClose(); }
+ MouseArea { id: mouseArea; anchors.fill: parent; onClicked: forceClose(); }
}
//![0]
diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.js b/examples/declarative/tutorials/samegame/samegame3/samegame.js
index 38efb3b..33449fa 100644
--- a/examples/declarative/tutorials/samegame/samegame3/samegame.js
+++ b/examples/declarative/tutorials/samegame/samegame3/samegame.js
@@ -14,12 +14,6 @@ function index(xIdx,yIdx) {
function initBoard()
{
- for(var i = 0; i<maxIndex; i++){
- //Delete old blocks
- if(board[i] != null)
- board[i].destroy();
- }
-
//Calculate board size
maxX = Math.floor(gameCanvas.width/gameCanvas.tileSize);
maxY = Math.floor(gameCanvas.height/gameCanvas.tileSize);
diff --git a/examples/declarative/tutorials/samegame/samegame3/samegame.qml b/examples/declarative/tutorials/samegame/samegame3/samegame.qml
index 168bf9b..db25e24 100644
--- a/examples/declarative/tutorials/samegame/samegame3/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame3/samegame.qml
@@ -1,12 +1,12 @@
//![0]
import Qt 4.6
+import "samegame.js" as SameGame
Rectangle {
id: screen
width: 490; height: 720
SystemPalette { id: activePalette }
- Script { source: "samegame.js" }
Item {
width: parent.width; anchors.top: parent.top; anchors.bottom: toolbar.top
@@ -28,8 +28,7 @@ Rectangle {
height: parent.height - (parent.height % tileSize);
MouseArea {
- id: gameMR
- anchors.fill: parent; onClicked: handleClick(mouse.x,mouse.y);
+ anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y);
}
}
//![1]
@@ -46,7 +45,7 @@ Rectangle {
anchors.bottom: screen.bottom
Button {
- id: btnA; text: "New Game"; onClicked: initBoard();
+ id: btnA; text: "New Game"; onClicked: SameGame.initBoard();
anchors.left: parent.left; anchors.leftMargin: 3
anchors.verticalCenter: parent.verticalCenter
}
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
index a6ef62c..e50aae0 100644
--- a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml
@@ -9,7 +9,7 @@ Item { id:block
property int targetX: 0
property int targetY: 0
- SpringFollow on x { enabled: spawned; source: targetX; spring: 2; damping: 0.2 }
+ SpringFollow on x { source: targetX; spring: 2; damping: 0.2; enabled: spawned }
SpringFollow on y { source: targetY; spring: 2; damping: 0.2 }
//![1]
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml
index 6629302..a7853d4 100644
--- a/examples/declarative/tutorials/samegame/samegame4/content/Button.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/content/Button.qml
@@ -13,11 +13,11 @@ Rectangle {
gradient: Gradient {
GradientStop {
id: topGrad; position: 0.0
- color: if (mr.pressed) { activePalette.dark } else { activePalette.light } }
+ color: if (mouseArea.pressed) { activePalette.dark } else { activePalette.light } }
GradientStop { position: 1.0; color: activePalette.button }
}
- MouseArea { id: mr; anchors.fill: parent; onClicked: container.clicked() }
+ MouseArea { id: mouseArea; anchors.fill: parent; onClicked: container.clicked() }
Text {
id: txtItem; text: container.text; anchors.centerIn: container; color: activePalette.buttonText
diff --git a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml
index 831c03b..fc83e39 100644
--- a/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/content/Dialog.qml
@@ -17,5 +17,5 @@ Rectangle {
NumberAnimation { duration: 1000 }
}
Text { id: myText; anchors.centerIn: parent; text: "Hello World!" }
- MouseArea { id: mr; anchors.fill: parent; onClicked: forceClose(); }
+ MouseArea { id: mouseArea; anchors.fill: parent; onClicked: forceClose(); }
}
diff --git a/examples/declarative/tutorials/samegame/samegame4/samegame.qml b/examples/declarative/tutorials/samegame/samegame4/samegame.qml
index c2e8018..090496d 100644
--- a/examples/declarative/tutorials/samegame/samegame4/samegame.qml
+++ b/examples/declarative/tutorials/samegame/samegame4/samegame.qml
@@ -1,5 +1,6 @@
import Qt 4.6
import "content"
+import "content/samegame.js" as SameGame
Rectangle {
id: screen
@@ -21,20 +22,19 @@ Rectangle {
property int score: 0
property int tileSize: 40
- Script { source: "content/samegame.js" }
-
z: 20; anchors.centerIn: parent
width: parent.width - (parent.width % getTileSize());
height: parent.height - (parent.height % getTileSize());
MouseArea {
- id: gameMR
- anchors.fill: parent; onClicked: handleClick(mouse.x,mouse.y);
+ anchors.fill: parent; onClicked: SameGame.handleClick(mouse.x,mouse.y);
}
}
}
Dialog { id: dialog; anchors.centerIn: parent; z: 21 }
+
+ //![0]
Dialog {
id: scoreName; anchors.centerIn: parent; z: 22;
Text {
@@ -54,6 +54,7 @@ Rectangle {
anchors.left: spacer.right
}
}
+ //![0]
Rectangle {
id: toolBar
@@ -62,7 +63,7 @@ Rectangle {
anchors.bottom: screen.bottom
Button {
- id: btnA; text: "New Game"; onClicked: {initBoard();}
+ id: btnA; text: "New Game"; onClicked: {SameGame.initBoard();}
anchors.left: parent.left; anchors.leftMargin: 3
anchors.verticalCenter: parent.verticalCenter
}