summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/snippets/declarative')
-rw-r--r--doc/src/snippets/declarative/SelfDestroyingRect.qml (renamed from doc/src/snippets/declarative/dynamicObjects.qml)37
-rw-r--r--doc/src/snippets/declarative/animation-behavioral.qml61
-rw-r--r--doc/src/snippets/declarative/animation-easing.qml51
-rw-r--r--doc/src/snippets/declarative/animation-elements.qml66
-rw-r--r--doc/src/snippets/declarative/animation-groups.qml104
-rw-r--r--doc/src/snippets/declarative/animation-propertyvaluesource.qml51
-rw-r--r--doc/src/snippets/declarative/animation-signalhandler.qml55
-rw-r--r--doc/src/snippets/declarative/animation-standalone.qml63
-rw-r--r--doc/src/snippets/declarative/animation-transitions.qml62
-rw-r--r--doc/src/snippets/declarative/animation.qml181
-rw-r--r--doc/src/snippets/declarative/component.qml60
-rw-r--r--doc/src/snippets/declarative/createComponent-simple.qml57
-rw-r--r--doc/src/snippets/declarative/createQmlObject.qml4
-rw-r--r--doc/src/snippets/declarative/dynamicObjects-destroy.qml55
-rw-r--r--doc/src/snippets/declarative/qmldocuments.qml66
-rw-r--r--doc/src/snippets/declarative/state-when.qml55
-rw-r--r--doc/src/snippets/declarative/state.qml18
-rw-r--r--doc/src/snippets/declarative/states.qml38
-rw-r--r--doc/src/snippets/declarative/transition.qml9
19 files changed, 852 insertions, 241 deletions
diff --git a/doc/src/snippets/declarative/dynamicObjects.qml b/doc/src/snippets/declarative/SelfDestroyingRect.qml
index 3698499..f14d2d2 100644
--- a/doc/src/snippets/declarative/dynamicObjects.qml
+++ b/doc/src/snippets/declarative/SelfDestroyingRect.qml
@@ -37,33 +37,24 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
+//![0]
import Qt 4.7
-//![0]
Rectangle {
- id: rootItem
- width: 300
- height: 300
-
- Component {
- id: rectComponent
-
- Rectangle {
- id: rect
- width: 40; height: 40;
- color: "red"
-
- NumberAnimation on opacity { from: 1; to: 0; duration: 1000 }
-
- Component.onCompleted: rect.destroy(1000);
+ id: rect
+ width: 80; height: 80
+ color: "red"
+
+ NumberAnimation on opacity {
+ to: 0
+ duration: 1000
+
+ onRunningChanged: {
+ if (!running) {
+ console.log("Destroying...")
+ rect.destroy();
+ }
}
}
-
- function createRectangle() {
- var object = rectComponent.createObject(rootItem);
- }
-
- Component.onCompleted: createRectangle()
}
//![0]
diff --git a/doc/src/snippets/declarative/animation-behavioral.qml b/doc/src/snippets/declarative/animation-behavioral.qml
new file mode 100644
index 0000000..dc79018
--- /dev/null
+++ b/doc/src/snippets/declarative/animation-behavioral.qml
@@ -0,0 +1,61 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Qt 4.7
+
+Item {
+ width: 100; height: 100
+
+ Rectangle {
+ id: rect
+ width: 100; height: 100
+ color: "red"
+
+ Behavior on x { PropertyAnimation { duration: 500 } }
+ Behavior on y { PropertyAnimation { duration: 500 } }
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: { rect.x = mouse.x; rect.y = mouse.y }
+ }
+}
+//![0]
+
diff --git a/doc/src/snippets/declarative/animation-easing.qml b/doc/src/snippets/declarative/animation-easing.qml
new file mode 100644
index 0000000..e65c470
--- /dev/null
+++ b/doc/src/snippets/declarative/animation-easing.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Qt 4.7
+
+Rectangle {
+ width: 100; height: 100
+ color: "red"
+
+ PropertyAnimation on x { to: 50; duration: 1000; easing.type: Easing.OutBounce }
+ PropertyAnimation on y { to: 50; duration: 1000; easing.type: Easing.OutBounce }
+}
+//![0]
+
diff --git a/doc/src/snippets/declarative/animation-elements.qml b/doc/src/snippets/declarative/animation-elements.qml
new file mode 100644
index 0000000..7cb253e
--- /dev/null
+++ b/doc/src/snippets/declarative/animation-elements.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Qt 4.7
+
+Row {
+
+//![color]
+Rectangle {
+ width: 100; height: 100
+
+ ColorAnimation on color { from: "red"; to: "yellow"; duration: 1000 }
+}
+//![color]
+
+//![rotation]
+Item {
+ width: 300; height: 300
+
+ Rectangle {
+ width: 100; height: 100; anchors.centerIn: parent
+ color: "red"
+
+ RotationAnimation on rotation { to: 90; direction: RotationAnimation.Clockwise }
+ }
+}
+//![rotation]
+
+}
diff --git a/doc/src/snippets/declarative/animation-groups.qml b/doc/src/snippets/declarative/animation-groups.qml
new file mode 100644
index 0000000..8a8f925
--- /dev/null
+++ b/doc/src/snippets/declarative/animation-groups.qml
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import Qt 4.7
+
+Row {
+
+//![0]
+Rectangle {
+ id: rect
+ width: 120; height: 200
+
+ Image {
+ id: img
+ source: "pics/qt.png"
+ anchors.horizontalCenter: parent.horizontalCenter
+ y: 0
+
+ SequentialAnimation on y {
+ loops: Animation.Infinite
+ NumberAnimation { to: rect.height - img.height; easing.type: Easing.OutBounce; duration: 2000 }
+ PauseAnimation { duration: 1000 }
+ NumberAnimation { to: 0; easing.type: Easing.OutQuad; duration: 1000 }
+ }
+ }
+}
+//![0]
+
+//![1]
+Rectangle {
+ id: redRect
+ width: 100; height: 100
+ color: "red"
+
+ MouseArea { id: mouseArea; anchors.fill: parent }
+
+ states: State {
+ name: "pressed"; when: mouseArea.pressed
+ PropertyChanges { target: redRect; color: "blue"; y: mouseArea.mouseY; width: mouseArea.mouseX }
+ }
+
+ transitions: Transition {
+
+ SequentialAnimation {
+ ColorAnimation { duration: 200 }
+ PauseAnimation { duration: 100 }
+
+ ParallelAnimation {
+ NumberAnimation {
+ duration: 500
+ easing.type: Easing.OutBounce
+ targets: redRect
+ properties: "y"
+ }
+
+ NumberAnimation {
+ duration: 800
+ easing.type: Easing.InOutQuad
+ targets: redRect
+ properties: "width"
+ }
+ }
+ }
+ }
+}
+//![1]
+
+}
diff --git a/doc/src/snippets/declarative/animation-propertyvaluesource.qml b/doc/src/snippets/declarative/animation-propertyvaluesource.qml
new file mode 100644
index 0000000..ac5f071
--- /dev/null
+++ b/doc/src/snippets/declarative/animation-propertyvaluesource.qml
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Qt 4.7
+
+Rectangle {
+ width: 100; height: 100
+ color: "red"
+
+ PropertyAnimation on x { to: 50; duration: 1000; loops: Animation.Infinite }
+ PropertyAnimation on y { to: 50; duration: 1000; loops: Animation.Infinite }
+}
+//![0]
+
diff --git a/doc/src/snippets/declarative/animation-signalhandler.qml b/doc/src/snippets/declarative/animation-signalhandler.qml
new file mode 100644
index 0000000..749596c
--- /dev/null
+++ b/doc/src/snippets/declarative/animation-signalhandler.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Qt 4.7
+
+Rectangle {
+ id: rect
+ width: 100; height: 100
+ color: "red"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: PropertyAnimation { target: rect; properties: "x,y"; to: 50; duration: 1000 }
+ }
+}
+
+//![0]
+
diff --git a/doc/src/snippets/declarative/animation-standalone.qml b/doc/src/snippets/declarative/animation-standalone.qml
new file mode 100644
index 0000000..d75fd92
--- /dev/null
+++ b/doc/src/snippets/declarative/animation-standalone.qml
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Qt 4.7
+
+Rectangle {
+ id: rect
+ width: 100; height: 100
+ color: "red"
+
+ PropertyAnimation {
+ id: animation
+ target: rect
+ properties: "x,y"
+ duration: 1000
+ }
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ animation.to = 50;
+ animation.running = true;
+ }
+ }
+}
+//![0]
diff --git a/doc/src/snippets/declarative/animation-transitions.qml b/doc/src/snippets/declarative/animation-transitions.qml
new file mode 100644
index 0000000..3265065
--- /dev/null
+++ b/doc/src/snippets/declarative/animation-transitions.qml
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Qt 4.7
+
+Rectangle {
+ id: rect
+ width: 100; height: 100
+ color: "red"
+
+ MouseArea {
+ anchors.fill: parent
+ onClicked: rect.state = "moved"
+ }
+
+ states: State {
+ name: "moved"
+ PropertyChanges { target: rect; x: 50; y: 50 }
+ }
+
+ transitions: Transition {
+ PropertyAnimation { properties: "x,y"; duration: 1000 }
+ }
+}
+//![0]
diff --git a/doc/src/snippets/declarative/animation.qml b/doc/src/snippets/declarative/animation.qml
deleted file mode 100644
index 65acd36..0000000
--- a/doc/src/snippets/declarative/animation.qml
+++ /dev/null
@@ -1,181 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtDeclarative module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-import Qt 4.7
-
-Row {
-
-//![property-anim-1]
-Rectangle {
- id: rect
- width: 120; height: 200
-
- Image {
- id: img
- source: "pics/qt.png"
- x: 60 - img.width/2
- y: 0
-
- SequentialAnimation on y {
- loops: Animation.Infinite
- NumberAnimation { to: 200 - img.height; easing.type: Easing.OutBounce; duration: 2000 }
- PauseAnimation { duration: 1000 }
- NumberAnimation { to: 0; easing.type: Easing.OutQuad; duration: 1000 }
- }
- }
-}
-//![property-anim-1]
-
-//![property-anim-2]
-Rectangle {
- width: 200; height: 200
-
- Rectangle {
- color: "red"
- width: 50; height: 50
- NumberAnimation on x { to: 50 }
- }
-}
-//![property-anim-2]
-
-
-Item {
-//![property-anim-3]
-PropertyAnimation {
- id: animation
- target: image
- property: "scale"
- from: 1; to: 0.5
-}
-
-Image {
- id: image
- source: "pics/qt.png"
- MouseArea {
- anchors.fill: parent
- onPressed: animation.start()
- }
-}
-//![property-anim-3]
-}
-
-
-//![transitions-1]
-transitions: [
- Transition {
- NumberAnimation {
- properties: "x,y"
- easing.type: Easing.OutBounce
- duration: 200
- }
- }
-]
-//![transitions-1]
-
-
-//![transitions-2]
-Transition {
- from: "*"
- to: "MyState"
- reversible: true
-
- SequentialAnimation {
- NumberAnimation {
- duration: 1000
- easing.type: Easing.OutBounce
-
- // animate myItem's x and y if they have changed in the state
- target: myItem
- properties: "x,y"
- }
-
- NumberAnimation {
- duration: 1000
-
- // animate myItem2's y to 200, regardless of what happens in the state
- target: myItem2
- property: "y"
- to: 200
- }
- }
-}
-//![transitions-2]
-
-
-//![transitions-3]
-Transition {
- from: "*"
- to: "MyState"
- reversible: true
-
- SequentialAnimation {
- ColorAnimation { duration: 1000 }
- PauseAnimation { duration: 1000 }
-
- ParallelAnimation {
- NumberAnimation {
- duration: 1000
- easing.type: Easing.OutBounce
- targets: box1
- properties: "x,y"
- }
- NumberAnimation {
- duration: 1000
- targets: box2
- properties: "x,y"
- }
- }
- }
-}
-//![transitions-3]
-
-//![behavior]
-Rectangle {
- id: redRect
- color: "red"
- width: 100; height: 100
-
- Behavior on x {
- NumberAnimation { duration: 300; easing.type: Easing.InOutQuad }
- }
-}
-//![behavior]
-
-}
diff --git a/doc/src/snippets/declarative/component.qml b/doc/src/snippets/declarative/component.qml
new file mode 100644
index 0000000..09c4aa2
--- /dev/null
+++ b/doc/src/snippets/declarative/component.qml
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Qt 4.7
+
+Item {
+ width: 100; height: 100
+
+ Component {
+ id: redSquare
+
+ Rectangle {
+ color: "red"
+ width: 10
+ height: 10
+ }
+ }
+
+ Loader { sourceComponent: redSquare }
+ Loader { sourceComponent: redSquare; x: 20 }
+}
+//![0]
diff --git a/doc/src/snippets/declarative/createComponent-simple.qml b/doc/src/snippets/declarative/createComponent-simple.qml
new file mode 100644
index 0000000..9669580
--- /dev/null
+++ b/doc/src/snippets/declarative/createComponent-simple.qml
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Qt 4.7
+
+Item {
+ id: container
+ width: 300; height: 300
+
+ function loadButton() {
+ var component = Qt.createComponent("Button.qml");
+ if (component.status == Component.Ready) {
+ var button = component.createObject(container);
+ button.color = "red";
+ }
+ }
+
+ Component.onCompleted: loadButton()
+}
+//![0]
diff --git a/doc/src/snippets/declarative/createQmlObject.qml b/doc/src/snippets/declarative/createQmlObject.qml
index 64dd21d..a5f15f4 100644
--- a/doc/src/snippets/declarative/createQmlObject.qml
+++ b/doc/src/snippets/declarative/createQmlObject.qml
@@ -51,6 +51,10 @@ Rectangle {
var newObject = Qt.createQmlObject('import Qt 4.7; Rectangle {color: "red"; width: 20; height: 20}',
parentItem, "dynamicSnippet1");
//![0]
+
+//![destroy]
+newObject.destroy(1000);
+//![destroy]
}
Component.onCompleted: createIt()
diff --git a/doc/src/snippets/declarative/dynamicObjects-destroy.qml b/doc/src/snippets/declarative/dynamicObjects-destroy.qml
new file mode 100644
index 0000000..2c0c2fb
--- /dev/null
+++ b/doc/src/snippets/declarative/dynamicObjects-destroy.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Qt 4.7
+
+Item {
+ id: container
+ width: 500; height: 100
+
+ Component.onCompleted: {
+ var component = Qt.createComponent("SelfDestroyingRect.qml");
+ for (var i=0; i<5; i++) {
+ var object = component.createObject(container);
+ object.x = (object.width + 10) * i;
+ }
+ }
+}
+//![0]
diff --git a/doc/src/snippets/declarative/qmldocuments.qml b/doc/src/snippets/declarative/qmldocuments.qml
new file mode 100644
index 0000000..c19a658
--- /dev/null
+++ b/doc/src/snippets/declarative/qmldocuments.qml
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+//![0]
+import Qt 4.7
+
+Rectangle {
+ property alias text: textItem.text
+
+ width: 100; height: 30
+ border.width: 1
+ radius: 5
+ smooth: true
+
+ gradient: Gradient {
+ GradientStop { position: 0.0; color: "darkGray" }
+ GradientStop { position: 0.5; color: "black" }
+ GradientStop { position: 1.0; color: "darkGray" }
+ }
+
+ Text {
+ id: textItem
+ anchors.centerIn: parent
+ font.pointSize: 20
+ color: "white"
+ }
+
+}
+//![0]
diff --git a/doc/src/snippets/declarative/state-when.qml b/doc/src/snippets/declarative/state-when.qml
new file mode 100644
index 0000000..6d3bb75
--- /dev/null
+++ b/doc/src/snippets/declarative/state-when.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+import Qt 4.7
+//![0]
+Rectangle {
+ id: myRect
+ width: 100; height: 100
+ color: "red"
+
+ MouseArea { id: mouseArea; anchors.fill: parent }
+
+ states: State {
+ name: "hidden"; when: mouseArea.pressed
+ PropertyChanges { target: myRect; opacity: 0 }
+ }
+}
+//![0]
diff --git a/doc/src/snippets/declarative/state.qml b/doc/src/snippets/declarative/state.qml
index af6b103..ce2653b 100644
--- a/doc/src/snippets/declarative/state.qml
+++ b/doc/src/snippets/declarative/state.qml
@@ -44,13 +44,19 @@ import Qt 4.7
Rectangle {
id: myRect
width: 100; height: 100
- color: "red"
+ color: "black"
- MouseArea { id: mouseArea; anchors.fill: parent }
-
- states: State {
- name: "hidden"; when: mouseArea.pressed
- PropertyChanges { target: myRect; opacity: 0 }
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onClicked: myRect.state == 'clicked' ? myRect.state = "" : myRect.state = 'clicked';
}
+
+ states: [
+ State {
+ name: "clicked"
+ PropertyChanges { target: myRect; color: "red" }
+ }
+ ]
}
//![0]
diff --git a/doc/src/snippets/declarative/states.qml b/doc/src/snippets/declarative/states.qml
index c3b1796..127e3a7 100644
--- a/doc/src/snippets/declarative/states.qml
+++ b/doc/src/snippets/declarative/states.qml
@@ -40,42 +40,22 @@
****************************************************************************/
//![0]
import Qt 4.7
-
-Item {
- id: myItem
+
+Rectangle {
+ id: myRect
width: 200; height: 200
+ color: "red"
- Rectangle {
- id: myRect
- width: 100; height: 100
- color: "red"
+ MouseArea {
+ anchors.fill: parent
+ onClicked: myRect.state = 'moved'
}
states: [
State {
name: "moved"
- PropertyChanges {
- target: myRect
- x: 50
- y: 50
- }
+ PropertyChanges { target: myRect; x: 50; y: 50 }
}
]
-
- MouseArea {
- anchors.fill: parent
- onClicked: myItem.state = 'moved'
- }
-//![0]
-
-//![transitions]
-transitions: [
- Transition {
- NumberAnimation { properties: "x,y"; duration: 500 }
- }
-]
-//![transitions]
-
-//![1]
}
-//![1]
+//![0]
diff --git a/doc/src/snippets/declarative/transition.qml b/doc/src/snippets/declarative/transition.qml
index b884750..098d509 100644
--- a/doc/src/snippets/declarative/transition.qml
+++ b/doc/src/snippets/declarative/transition.qml
@@ -46,13 +46,18 @@ Rectangle {
width: 100; height: 100
color: "red"
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ }
+
states: State {
- name: "moved"
+ name: "moved"; when: mouseArea.pressed
PropertyChanges { target: rect; x: 50; y: 50 }
}
transitions: Transition {
- PropertyAnimation { properties: "x,y"; easing.type: Easing.InOutQuad }
+ NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad }
}
}
//![0]