summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-07-28 06:21:42 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-07-29 00:51:25 (GMT)
commitceeb0fc0327c99de55d4dd6114908ec389dc58eb (patch)
tree4cdc0f94b9a90bb860adb0456418419afafb4edb /doc/src/snippets
parent2573e7b14b8584f7ccc866685b4a7d76a9c7af5f (diff)
downloadQt-ceeb0fc0327c99de55d4dd6114908ec389dc58eb.zip
Qt-ceeb0fc0327c99de55d4dd6114908ec389dc58eb.tar.gz
Qt-ceeb0fc0327c99de55d4dd6114908ec389dc58eb.tar.bz2
Fixes for Dynamic Object Management docs. Also adds links to
this page from other documentation. Task-number: QTBUG-12446
Diffstat (limited to 'doc/src/snippets')
-rw-r--r--doc/src/snippets/declarative/createComponent-simple.qml (renamed from doc/src/snippets/declarative/dynamicObjects.qml)32
-rw-r--r--doc/src/snippets/declarative/createQmlObject.qml4
-rw-r--r--doc/src/snippets/declarative/dynamicObjects-destroy.qml55
3 files changed, 69 insertions, 22 deletions
diff --git a/doc/src/snippets/declarative/dynamicObjects.qml b/doc/src/snippets/declarative/createComponent-simple.qml
index 3698499..9669580 100644
--- a/doc/src/snippets/declarative/dynamicObjects.qml
+++ b/doc/src/snippets/declarative/createComponent-simple.qml
@@ -37,33 +37,21 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-
-import Qt 4.7
-
//![0]
-Rectangle {
- id: rootItem
- width: 300
- height: 300
-
- Component {
- id: rectComponent
-
- Rectangle {
- id: rect
- width: 40; height: 40;
- color: "red"
+import Qt 4.7
- NumberAnimation on opacity { from: 1; to: 0; duration: 1000 }
+Item {
+ id: container
+ width: 300; height: 300
- Component.onCompleted: rect.destroy(1000);
+ function loadButton() {
+ var component = Qt.createComponent("Button.qml");
+ if (component.status == Component.Ready) {
+ var button = component.createObject(container);
+ button.color = "red";
}
}
- function createRectangle() {
- var object = rectComponent.createObject(rootItem);
- }
-
- Component.onCompleted: createRectangle()
+ 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]