summaryrefslogtreecommitdiffstats
path: root/doc/src/declarative/dynamicobjects.qdoc
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/declarative/dynamicobjects.qdoc')
-rw-r--r--doc/src/declarative/dynamicobjects.qdoc42
1 files changed, 23 insertions, 19 deletions
diff --git a/doc/src/declarative/dynamicobjects.qdoc b/doc/src/declarative/dynamicobjects.qdoc
index f2ca0fdeff..90fb715e19 100644
--- a/doc/src/declarative/dynamicobjects.qdoc
+++ b/doc/src/declarative/dynamicobjects.qdoc
@@ -27,13 +27,17 @@
/*!
\page qdeclarativedynamicobjects.html
+\ingroup qml-features
+\contentspage {QML Features}
+\previouspage {Integrating QML Code with Existing Qt UI Code}
+\nextpage {Network Transparency}{Loading Resources in QML}
\title Dynamic Object Management in QML
-QML provides a number of ways to dynamically create and manage QML objects.
+QML provides a number of ways to dynamically create and manage QML objects.
The \l{Loader}, \l{Repeater}, \l{ListView}, \l{GridView} and \l{PathView} elements
-all support dynamic object management. Objects can also be created and managed
+all support dynamic object management. Objects can also be created and managed
from C++, and this is the preferred method for hybrid QML/C++ applications
-(see \l{Using QML in C++ Applications}).
+(see \l{Using QML Bindings in C++ Applications}).
QML also supports the dynamic creation of objects from within JavaScript
code. This is useful if the existing QML elements do not fit the needs of your
@@ -45,24 +49,24 @@ of the concepts discussed on this page.
\section1 Creating Objects Dynamically
-There are two ways to create objects dynamically from JavaScript. You can either call
+There are two ways to create objects dynamically from JavaScript. You can either call
\l {QML:Qt::createComponent()}{Qt.createComponent()} to dynamically create
a \l Component object, or use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}
to create an item from a string of QML.
-Creating a component is better if you have an existing component defined in a \c .qml
+Creating a component is better if you have an existing component defined in a \c .qml
file, and you want to dynamically create instances of that component. Otherwise,
-creating an item from a string of QML is useful when the item QML itself is generated
+creating an item from a string of QML is useful when the item QML itself is generated
at runtime.
-\section2 Creating a Component dynamically
+\section2 Creating a Component Dynamically
-To dynamically load a component defined in a QML file, call the
-\l {QML:Qt::createComponent()}{Qt.createComponent()} function on the \l{QML Global Object}.
+To dynamically load a component defined in a QML file, call the
+\l {QML:Qt::createComponent()}{Qt.createComponent()} function on the \l{QML Global Object}.
This function takes the URL of the QML file as its only argument and creates
a \l Component object from this URL.
-Once you have a \l Component, you can call its \l {Component::createObject()}{createObject()} method to create an instance of
+Once you have a \l Component, you can call its \l {Component::createObject()}{createObject()} method to create an instance of
the component. This function can take one or two arguments:
\list
\o The first is the parent for the new item. Since graphical items will not appear on the scene without a parent, it is
@@ -96,25 +100,27 @@ in case the QML file is loaded over a network and thus is not ready immediately.
\codeline
\snippet doc/src/snippets/declarative/componentCreation.js finishCreation
-If you are certain the QML file to be loaded is a local file, you could omit the \c finishCreation()
+If you are certain the QML file to be loaded is a local file, you could omit the \c finishCreation()
function and call \l {Component::createObject()}{createObject()} immediately:
\snippet doc/src/snippets/declarative/componentCreation.js func
\snippet doc/src/snippets/declarative/componentCreation.js local
\snippet doc/src/snippets/declarative/componentCreation.js func-end
-Notice in both instances, \l {Component::createObject()}{createObject()} is called with
+Notice in both instances, \l {Component::createObject()}{createObject()} is called with
\c appWindow passed as an argument so that the created object will become a child of the
\c appWindow item in \c main.qml. Otherwise, the new item will not appear in the scene.
When using files with relative paths, the path should
be relative to the file where \l {QML:Qt::createComponent()}{Qt.createComponent()} is executed.
-To connect signals to (or receive signals from) dynamically created objects, use the signal
-\c connect() method. See \l {Connecting signals to methods and other signals} for more information.
+To connect signals to (or receive signals from) dynamically created objects,
+use the signal \c connect() method. See
+\l{QML Signal and Handler Event System#Connecting Signals to Methods and Signals}
+{Connecting Signals to Methods and Signals} for more information.
-\section2 Creating an object from a string of QML
+\section2 Creating an Object from a String of QML
If the QML is not defined until runtime, you can create a QML item from
a string of QML using the \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} function, as in the following example:
@@ -164,7 +170,7 @@ 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.
+before the object is to be destroyed.
Here is an example. The \c application.qml creates five instances of the \c SelfDestroyingRect.qml
component. Each instance runs a NumberAnimation, and when the animation has finished, calls
@@ -198,7 +204,7 @@ Item {
}
\endqml
-This would result in an error, since items can only be dynamically
+This would result in an error, since items can only be dynamically
destroyed if they were dynamically created.
Objects created with \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}
@@ -206,6 +212,4 @@ can similarly be destroyed using \c destroy():
\snippet doc/src/snippets/declarative/createQmlObject.qml 0
\snippet doc/src/snippets/declarative/createQmlObject.qml destroy
-
*/
-