summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-05-04 01:13:24 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-05-04 01:14:11 (GMT)
commit56dcdada14f1a499da5a458bdada2127e73dc630 (patch)
tree8abc1ebc66ee494461ec3eda7fd29b468340ac04 /doc
parent536d0f141a13474122f99daf98bf6b54e635b474 (diff)
downloadQt-56dcdada14f1a499da5a458bdada2127e73dc630.zip
Qt-56dcdada14f1a499da5a458bdada2127e73dc630.tar.gz
Qt-56dcdada14f1a499da5a458bdada2127e73dc630.tar.bz2
Doc improvements
Diffstat (limited to 'doc')
-rw-r--r--doc/src/declarative/dynamicobjects.qdoc48
-rw-r--r--doc/src/snippets/declarative/dynamicObjects.qml30
-rw-r--r--doc/src/snippets/declarative/flickableScrollbar.qml26
3 files changed, 74 insertions, 30 deletions
diff --git a/doc/src/declarative/dynamicobjects.qdoc b/doc/src/declarative/dynamicobjects.qdoc
index 5cdd768..dc0277d 100644
--- a/doc/src/declarative/dynamicobjects.qdoc
+++ b/doc/src/declarative/dynamicobjects.qdoc
@@ -132,36 +132,24 @@ do not have an id in QML.
\section1 Deleting Objects Dynamically
-You should generally avoid dynamically deleting objects that you did not
-dynamically create. In many UIs, it is sufficient to set the opacity to 0 or
-to move the item off of the edge of the screen. If you have lots of dynamically
-created items however, deleting them when they are no longer used will provide
-a worthwhile performance benefit. Note that you should never manually delete
-items which were dynamically created by QML Elements such as \l{Loader}.
-
-To manually delete a QML item, call its destroy method. This method has one
-argument, which is an approximate delay in milliseconds and which defaults to zero. This
-allows you to wait until the completion of an animation or transition. An example:
-
-\code
- Component {
- id: fadesOut
- Rectangle{
- id: rect
- width: 40; height: 40;
- NumberAnimation on opacity { from:1; to:0; duration: 1000 }
- Component.onCompleted: rect.destroy(1000);
- }
- }
- function createFadesOut(parentItem)
- {
- var object = fadesOut.createObject();
- object.parent = parentItem;
- }
-\endcode
-
-In the above example, the dynamically created rectangle calls destroy as soon as it is created,
- but delays long enough for its fade out animation to be played.
+In many user interfaces, it is sufficient to set an item's opacity to 0 or
+to move the item off the screen instead of deleting the item. If you have
+lots of dynamically created items, however, you may receive a worthwhile
+performance benefit if unused items are deleted.
+
+Note that you should never manually delete items that were dynamically created
+by QML elements (such as \l Loader). Also, you should generally avoid deleting
+items that you did not dynamically create yourself.
+
+Items can be deleted using the \c destroy() method. This method has an optional
+argument (which defaults to 0) that specifies the approximate delay in milliseconds
+before the object is to be destroyed. This allows you to wait until the completion of
+an animation or transition. An example:
+
+\snippet doc/src/snippets/declarative/dynamicObjects.qml 0
+
+Here, \c Rectangle objects are destroyed one second after they are created, which is long
+enough for the \c NumberAnimation to be played before the object is destroyed.
*/
diff --git a/doc/src/snippets/declarative/dynamicObjects.qml b/doc/src/snippets/declarative/dynamicObjects.qml
new file mode 100644
index 0000000..dd55d78
--- /dev/null
+++ b/doc/src/snippets/declarative/dynamicObjects.qml
@@ -0,0 +1,30 @@
+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);
+ }
+ }
+
+ function createRectangle() {
+ var object = rectComponent.createObject();
+ object.parent = rootItem;
+ }
+
+ Component.onCompleted: createRectangle()
+}
+//![0]
diff --git a/doc/src/snippets/declarative/flickableScrollbar.qml b/doc/src/snippets/declarative/flickableScrollbar.qml
new file mode 100644
index 0000000..147751a
--- /dev/null
+++ b/doc/src/snippets/declarative/flickableScrollbar.qml
@@ -0,0 +1,26 @@
+import Qt 4.7
+
+//![0]
+Rectangle {
+ width: 200; height: 200
+
+ Flickable {
+ id: flickable
+//![0]
+ anchors.fill: parent
+ contentWidth: image.width; contentHeight: image.height
+
+ Image { id: image; source: "pics/qt.png" }
+//![1]
+ }
+
+ Rectangle {
+ id: scrollbar
+ anchors.right: flickable.right
+ y: flickable.visibleArea.yPosition * flickable.height
+ width: 10
+ height: flickable.visibleArea.heightRatio * flickable.height
+ color: "black"
+ }
+}
+//![1]