summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-03-07 04:24:44 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-03-07 04:24:44 (GMT)
commit9bc81769eb6ebc9bd62fe3c1d86e67ddccbed8b6 (patch)
treedff935d34574a362415c61c5000d019113ee08ec /examples
parente56ae7fb7b269afe36a3bd2f4de0c10f8c2a6924 (diff)
parent89e22c539702fbac311b3626e9407e2693579e72 (diff)
downloadQt-9bc81769eb6ebc9bd62fe3c1d86e67ddccbed8b6.zip
Qt-9bc81769eb6ebc9bd62fe3c1d86e67ddccbed8b6.tar.gz
Qt-9bc81769eb6ebc9bd62fe3c1d86e67ddccbed8b6.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: (25 commits) optimize dynamic call-by-name away Add support for QtScript connect/disconnect syntax in QML Minor perf improvement when running QML script blocks Fix qdeclarative{audio,video} tests. Don't assume documents are in UTF-8. Add basic support for explicit newParent in ParentAnimation. Delete uninspiring example. Fix compiler warning on RVCT Use new enum syntax for value types. Expect fail in currentIndex test for now. Allow unquoted enum syntax for value types More declarative examples cleanup. Improve declarative tabs example. Fix test leaks Use _data() for some tests Add missing NOTIFYs to timer, xmllistmodel, xmlrole Document new ParentChange properties. declarative examples cleanup Fix test Update QmlChanges.txt ...
Diffstat (limited to 'examples')
-rw-r--r--examples/declarative/anchors/anchor-changes.qml46
-rw-r--r--examples/declarative/behaviours/MyRect.qml13
-rw-r--r--examples/declarative/dynamic/dynamic.qml42
-rw-r--r--examples/declarative/fonts/fonts.qml35
-rw-r--r--examples/declarative/listview/itemlist.qml8
-rw-r--r--examples/declarative/mousearea/mouse.qml (renamed from examples/declarative/mouseregion/mouse.qml)0
-rw-r--r--examples/declarative/plugins/com/nokia/TimeExample/Clock.qml8
-rw-r--r--examples/declarative/searchbox/main.qml6
-rw-r--r--examples/declarative/tabwidget/TabWidget.qml44
-rw-r--r--examples/declarative/tabwidget/tab.pngbin0 -> 507 bytes
-rw-r--r--examples/declarative/tabwidget/tabs.qml49
-rw-r--r--examples/declarative/velocity/Day.qml6
12 files changed, 107 insertions, 150 deletions
diff --git a/examples/declarative/anchors/anchor-changes.qml b/examples/declarative/anchors/anchor-changes.qml
deleted file mode 100644
index 99ca3db..0000000
--- a/examples/declarative/anchors/anchor-changes.qml
+++ /dev/null
@@ -1,46 +0,0 @@
-import Qt 4.6
-
-Item {
- id: window
- width: 200; height: 450
-
- Rectangle {
- id: titleBar; color: "Gray"
- anchors.top: parent.top; height: 50
- width: parent.width
- }
-
- Rectangle {
- id: statusBar; color: "Gray"
- height: 50; anchors.bottom: parent.bottom
- width: parent.width
- }
-
- Rectangle {
- id: content
- anchors.top: titleBar.bottom; anchors.bottom: statusBar.top
- width: parent.width
-
- Text { text: "Top"; anchors.top: parent.top }
- Text { text: "Bottom"; anchors.bottom: parent.bottom }
- }
-
- MouseArea {
- anchors.fill: content
- onPressed: window.state = "FullScreen"
- onReleased: window.state = ""
- }
-
- states : State {
- name: "FullScreen"
- //! [0]
- AnchorChanges {
- target: content; top: window.top; bottom: window.bottom
- }
- //! [0]
- }
-
- transitions : Transition {
- NumberAnimation { properties: "y,height" }
- }
-}
diff --git a/examples/declarative/behaviours/MyRect.qml b/examples/declarative/behaviours/MyRect.qml
deleted file mode 100644
index caf0d83..0000000
--- a/examples/declarative/behaviours/MyRect.qml
+++ /dev/null
@@ -1,13 +0,0 @@
-import Qt 4.6
-
-Rectangle {
- radius: 15
- border.color: "black"
- width: 100
- height: 100
- id: page
- MouseArea {
- anchors.fill: parent
- onClicked: { bluerect.parent = page; bluerect.x=0 }
- }
-}
diff --git a/examples/declarative/dynamic/dynamic.qml b/examples/declarative/dynamic/dynamic.qml
index 2831b0c..6af3e81 100644
--- a/examples/declarative/dynamic/dynamic.qml
+++ b/examples/declarative/dynamic/dynamic.qml
@@ -17,15 +17,17 @@ Item {
}
// stars (when there's no sun)
- Particles { id: stars
- x: 0; y: 0; width: parent.width; height: parent.height/2
+ Particles {
+ id: stars
+ x: 0; y: 0; width: parent.width; height: parent.height / 2
source: "images/star.png"; angleDeviation: 360; velocity: 0
velocityDeviation: 0; count: parent.width / 10; fadeInDuration: 2800
opacity: 1
}
// ground, which has a z such that the sun can set behind it
- Rectangle { id: ground
+ Rectangle {
+ id: ground
z: 2
anchors { left: parent.left; top: parent.verticalCenter; right: toolbox.right; bottom: parent.bottom }
gradient: Gradient {
@@ -35,7 +37,8 @@ Item {
}
//Day state, for when you place a sun
- states: State { name: "Day"; when: window.activeSuns > 0
+ states: State {
+ name: "Day"; when: window.activeSuns > 0
PropertyChanges { target: stopA; color: "DeepSkyBlue"}
PropertyChanges { target: stopB; color: "SkyBlue"}
PropertyChanges { target: stars; opacity: 0 }
@@ -56,56 +59,57 @@ Item {
width: 480
anchors { right: parent.right; top:parent.top; bottom: parent.bottom }
Rectangle { //Not a child of any positioner
- color: "white"; border.color: "black";
+ color: "white"; border.color: "black";
width: toolRow.width + 4
height: toolRow.height + 4
x: toolboxPositioner.x + toolRow.x - 2
y: toolboxPositioner.y + toolRow.y - 2
}
- Column{
+ Column {
id: toolboxPositioner
anchors.centerIn: parent
spacing: 8
- Text{ text: "Drag an item into the scene." }
- Row{ id: toolRow
- spacing: 8;
- PaletteItem{
+ Text { text: "Drag an item into the scene." }
+ Row {
+ id: toolRow
+ spacing: 8;
+ PaletteItem {
anchors.verticalCenter: parent.verticalCenter
file: "Sun.qml";
image: "../images/sun.png"
}
- PaletteItem{
+ PaletteItem {
file: "GenericItem.qml"
image: "../images/moon.png"
}
- PaletteItem{
+ PaletteItem {
anchors.verticalCenter: parent.verticalCenter
file: "PerspectiveItem.qml"
image: "../images/tree_s.png"
}
- PaletteItem{
+ PaletteItem {
anchors.verticalCenter: parent.verticalCenter
file: "PerspectiveItem.qml"
image: "../images/rabbit_brown.png"
}
- PaletteItem{
+ PaletteItem {
anchors.verticalCenter: parent.verticalCenter
file: "PerspectiveItem.qml"
image: "../images/rabbit_bw.png"
}
}
- Text{ text: "Active Suns: " + activeSuns }
+ Text { text: "Active Suns: " + activeSuns }
Rectangle { width: 440; height: 1; color: "black" }
- Text{ text: "Arbitrary QML: " }
+ Text { text: "Arbitrary QML: " }
TextEdit {
id: qmlText
width: 460
height: 220
readOnly: false
focusOnPress: true
- font.pixelSize: 16
-
- text: "import Qt 4.6\nImage { id: smile;\n x: 500*Math.random();\n y: 200*Math.random(); \n source: 'images/face-smile.png';\n opacity: NumberAnimation{ \n to: 0; duration: 1500;\n }\n Component.onCompleted: smile.destroy(1500);\n}"
+ font.pixelSize: 14
+
+ text: "import Qt 4.6\nImage {\n id: smile;\n x: 500*Math.random();\n y: 200*Math.random(); \n source: 'images/face-smile.png';\n NumberAnimation on opacity { \n to: 0; duration: 1500;\n }\n Component.onCompleted: smile.destroy(1500);\n}"
}
Button {
text: "Create"
diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml
index 275ad43..e928df4 100644
--- a/examples/declarative/fonts/fonts.qml
+++ b/examples/declarative/fonts/fonts.qml
@@ -7,43 +7,40 @@ Rectangle {
color: "steelblue"
FontLoader { id: fixedFont; name: "Courier" }
-
FontLoader { id: localFont; source: "fonts/tarzenau-ocr-a.ttf" }
-
FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" }
- FontLoader { id: webFont2; source: "http://wrong.address.org" }
Column {
- anchors.fill: parent; spacing: 10
+ anchors.fill: parent; spacing: 15
anchors.leftMargin: 10; anchors.rightMargin: 10
Text {
text: myText; color: "lightsteelblue"
width: parent.width; elide: Text.ElideRight
- font.family: "Times"; font.pointSize: 36
+ font.family: "Times"; font.pointSize: 42
}
Text {
text: myText; color: "lightsteelblue"
width: parent.width; elide: Text.ElideLeft
- font.family: "Times"; font.pointSize: 36
- font.capitalization: "AllUppercase"
+ font.family: "Times"; font.pointSize: 42
+ font.capitalization: Font.AllUppercase
}
Text {
text: myText; color: "lightsteelblue"
width: parent.width; elide: Text.ElideMiddle
- font.family: fixedFont.name; font.pointSize: 36; font.weight: "Bold"
- font.capitalization: "AllLowercase"
+ font.family: fixedFont.name; font.pointSize: 42; font.weight: Font.Bold
+ font.capitalization: Font.AllLowercase
}
Text {
text: myText; color: "lightsteelblue"
width: parent.width; elide: Text.ElideRight
- font.family: fixedFont.name; font.pointSize: 36; font.italic: true
- font.capitalization: "SmallCaps"
+ font.family: fixedFont.name; font.pointSize: 42; font.italic: true
+ font.capitalization: Font.SmallCaps
}
Text {
text: myText; color: "lightsteelblue"
width: parent.width; elide: Text.ElideLeft
- font.family: localFont.name; font.pointSize: 36
- font.capitalization: "Capitalize"
+ font.family: localFont.name; font.pointSize: 42
+ font.capitalization: Font.Capitalize
}
Text {
text: {
@@ -53,17 +50,7 @@ Rectangle {
}
color: "lightsteelblue"
width: parent.width; elide: Text.ElideMiddle
- font.family: webFont.name; font.pointSize: 36
- }
- Text {
- text: {
- if (webFont2.status == 1) myText
- else if (webFont2.status == 2) "Loading..."
- else if (webFont2.status == 3) "Error loading font"
- }
- color: "lightsteelblue"
- width: parent.width; elide: Text.ElideRight
- font.family: webFont2.name; font.pointSize: 36
+ font.family: webFont.name; font.pointSize: 42
}
}
}
diff --git a/examples/declarative/listview/itemlist.qml b/examples/declarative/listview/itemlist.qml
index 54981b7..41aa860 100644
--- a/examples/declarative/listview/itemlist.qml
+++ b/examples/declarative/listview/itemlist.qml
@@ -26,14 +26,12 @@ Rectangle {
ListView {
id: view
- anchors.fill: parent
- anchors.bottomMargin: 30
+ anchors.fill: parent; anchors.bottomMargin: 30
model: itemModel
- preferredHighlightBegin: 0
- preferredHighlightEnd: 0
+ preferredHighlightBegin: 0; preferredHighlightEnd: 0
highlightRangeMode: "StrictlyEnforceRange"
orientation: ListView.Horizontal
- flickDeceleration: 2000
+ snapMode: ListView.SnapOneItem; flickDeceleration: 2000
}
Rectangle {
diff --git a/examples/declarative/mouseregion/mouse.qml b/examples/declarative/mousearea/mouse.qml
index 9191f8a..9191f8a 100644
--- a/examples/declarative/mouseregion/mouse.qml
+++ b/examples/declarative/mousearea/mouse.qml
diff --git a/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml
index 01ec686..622fcf9 100644
--- a/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml
+++ b/examples/declarative/plugins/com/nokia/TimeExample/Clock.qml
@@ -1,8 +1,8 @@
import Qt 4.6
-Item {
+Rectangle {
id: clock
- width: 200; height: 200
+ width: 200; height: 200; color: "gray"
property alias city: cityLabel.text
property var hours
@@ -18,7 +18,7 @@ Item {
transform: Rotation {
id: hourRotation
origin.x: 7.5; origin.y: 73; angle: 0
- angle: SpringFollow {
+ SpringFollow on angle {
spring: 2; damping: 0.2; modulus: 360
source: (clock.hours * 30) + (clock.minutes * 0.5)
}
@@ -32,7 +32,7 @@ Item {
transform: Rotation {
id: minuteRotation
origin.x: 6.5; origin.y: 83; angle: 0
- angle: SpringFollow {
+ SpringFollow on angle {
spring: 2; damping: 0.2; modulus: 360
source: clock.minutes * 6
}
diff --git a/examples/declarative/searchbox/main.qml b/examples/declarative/searchbox/main.qml
index 39c3720..9b33be3 100644
--- a/examples/declarative/searchbox/main.qml
+++ b/examples/declarative/searchbox/main.qml
@@ -6,8 +6,8 @@ Rectangle {
Column {
anchors.horizontalCenter: parent.horizontalCenter; anchors.verticalCenter: parent.verticalCenter; spacing: 10
- SearchBox { id: search1; KeyNavigation.down: search2; focus: true }
- SearchBox { id: search2; KeyNavigation.up: search1; KeyNavigation.down: search3 }
- SearchBox { id: search3; KeyNavigation.up: search2 }
+ SearchBox { id: search1; KeyNavigation.tab: search2; KeyNavigation.backtab: search3; focus: true }
+ SearchBox { id: search2; KeyNavigation.tab: search3; KeyNavigation.backtab: search1 }
+ SearchBox { id: search3; KeyNavigation.tab: search1; KeyNavigation.backtab: search2 }
}
}
diff --git a/examples/declarative/tabwidget/TabWidget.qml b/examples/declarative/tabwidget/TabWidget.qml
index f0dfee8..f0f7164 100644
--- a/examples/declarative/tabwidget/TabWidget.qml
+++ b/examples/declarative/tabwidget/TabWidget.qml
@@ -1,42 +1,50 @@
import Qt 4.6
Item {
- id: page
+ id: tabWidget
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
+ for (var i = 0; i < stack.children.length; ++i) {
+ stack.children[i].opacity = i == current ? 1 : 0
}
}
+
Row {
id: header
Repeater {
delegate:
+ Rectangle {
+ width: tabWidget.width / stack.children.length; height: 36
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
- }
- MouseArea {
- anchors.fill: parent
- onClicked: page.current = index
- }
+ color: "#acb2c2"; width: parent.width; height: 1
+ anchors { bottom: parent.bottom; bottomMargin: 1 }
+ }
+ BorderImage {
+ source: "tab.png"; visible: tabWidget.current == index; border.left: 7; border.right: 7
+ anchors { fill: parent; leftMargin: 2; topMargin: 5; rightMargin: 1 }
}
+ Text {
+ horizontalAlignment: Qt.AlignHCenter; verticalAlignment: Qt.AlignVCenter
+ anchors.fill: parent; text: stack.children[index].title
+ elide: Text.ElideRight; font.bold: tabWidget.current == index
+ }
+ MouseArea {
+ anchors.fill: parent
+ onClicked: tabWidget.current = index
+ }
+ }
model: stack.children.length
}
}
+
Item {
id: stack
- anchors.top: header.bottom
- anchors.bottom: page.bottom
- width: page.width
+ anchors.top: header.bottom; anchors.bottom: tabWidget.bottom; width: tabWidget.width
}
}
diff --git a/examples/declarative/tabwidget/tab.png b/examples/declarative/tabwidget/tab.png
new file mode 100644
index 0000000..ad80216
--- /dev/null
+++ b/examples/declarative/tabwidget/tab.png
Binary files differ
diff --git a/examples/declarative/tabwidget/tabs.qml b/examples/declarative/tabwidget/tabs.qml
index 54ed7df..1d11b03 100644
--- a/examples/declarative/tabwidget/tabs.qml
+++ b/examples/declarative/tabwidget/tabs.qml
@@ -2,28 +2,47 @@ import Qt 4.6
TabWidget {
id: tabs
- width: 200
- height: 200
- current: 2
+ width: 640; height: 480
+
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 }
+ anchors.fill: parent; color: "#e3e3e3"
+ Rectangle {
+ anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ color: "#ff7f7f"
+ Text {
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Roses are red"; font.pixelSize: 20
+ 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 }
+ anchors.fill: parent; color: "#e3e3e3"
+ Rectangle {
+ anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ color: "#7fff7f"
+ Text {
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Flower stems are green"; font.pixelSize: 20
+ 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 }
+ anchors.fill: parent; color: "#e3e3e3"
+ Rectangle {
+ anchors { fill: parent; topMargin: 20; leftMargin: 20; rightMargin: 20; bottomMargin: 20 }
+ color: "#7f7fff"
+ Text {
+ anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter
+ text: "Violets are blue"; font.pixelSize: 20
+ wrap: true; width: parent.width - 20
+ }
+ }
}
}
diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml
index 7424f60..f4c24a5 100644
--- a/examples/declarative/velocity/Day.qml
+++ b/examples/declarative/velocity/Day.qml
@@ -33,7 +33,7 @@ Rectangle {
id: sticky
scale: 0.5
Image {
- id: stickyImage; source: "sticky.png"
+ id: stickyImage; source: "sticky.png"; transformOrigin: Item.TopLeft
smooth: true; y: -20; x: 8 + -width * 0.6 / 2; scale: 0.6
}
@@ -52,14 +52,14 @@ Rectangle {
id: mouse
onClicked: { myText.focus = true }
anchors.fill: parent
- drag.target: stickyPage; drag.axis: "XandYAxis"; drag.minimumY: 0; drag.maximumY: 500
+ drag.target: stickyPage; drag.axis: MouseArea.XandYAxis; drag.minimumY: 0; drag.maximumY: 500
drag.minimumX: 0; drag.maximumX: 400
}
}
}
Image {
- source: "tack.png"
+ source: "tack.png"; transformOrigin: Item.TopLeft
x: -width / 2; y: -height * 0.7 / 2; scale: 0.7
}