summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativecomponent.cpp
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-03-16 02:59:44 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-03-16 02:59:44 (GMT)
commit0c204981816f626a091f28f91cd25f49d7b74528 (patch)
tree0f67931ff94feafa8b76cfd22064220ee4986fe0 /src/declarative/qml/qdeclarativecomponent.cpp
parent758a4446810e96eb4e2f0b0099b996701945422b (diff)
parent82ae515e52e3811d3b2aec588e0dd777350c1c33 (diff)
downloadQt-0c204981816f626a091f28f91cd25f49d7b74528.zip
Qt-0c204981816f626a091f28f91cd25f49d7b74528.tar.gz
Qt-0c204981816f626a091f28f91cd25f49d7b74528.tar.bz2
Merge branch 'master' of git://scm.dev.nokia.troll.no/qt/qt-qml-team
* 'master' of git://scm.dev.nokia.troll.no/qt/qt-qml-team: (345 commits) QS60Style: QTreeView::indexRowSizeHint returns incorrect value Fix TextEdit mouseSelectionMode overriding selectByMouse. Deprecate QScriptValue::UserRange Deprecate QScriptValue::QObjectMember Fix static text item positioning GL2 paint engine Fix combining marks handling in Core Text shaper Update QML "What's New" docs. Don't reveal TextInput text on refocus in PasswordEchoOnEdit mode. Fix ListView boundary extents for RTL layout. Fix compiler warning. Update copyright year to 2011. Fix for major regression in OpenVG clipping Fix QGraphicsScene returning incorrect focus item. Cast int to HALData::TAttribute for QT_HALData_ENumCpus and compile with RVCT4. Not requiring valid QTextBlock in previous() Don't use EGL surfaces for translucency with 32MB GPU chip. Fix for fromSymbianCFbsBitmap changing the source data unexpectedly. Background app visible after split view closed Configuring a static Qt build did not exclude WebKit if the -webkit option was given. Get the number of cores from HAL on Symbian. ...
Diffstat (limited to 'src/declarative/qml/qdeclarativecomponent.cpp')
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index cf40182..fc393d1 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -615,10 +615,11 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
}
/*!
- \qmlmethod object Component::createObject(Item parent, Script valuemap = null)
+ \qmlmethod object Component::createObject(Item parent, object properties)
- Creates and returns an object instance of this component that will have the given
- \a parent. Returns null if object creation fails.
+ Creates and returns an object instance of this component that will have
+ the given \a parent and \a properties. The \a properties argument is optional.
+ Returns null if object creation fails.
The object will be created in the same context as the one in which the component
was created. This function will always return null when called on components
@@ -630,14 +631,23 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
property, or else the object will not be visible.
If a \a parent is not provided to createObject(), a reference to the returned object must be held so that
- it is not destroyed by the garbage collector. This is regardless of Item.parent being set afterwards,
+ it is not destroyed by the garbage collector. This is true regardless of whether \l{Item::parent} is set afterwards,
since setting the Item parent does not change object ownership; only the graphical parent is changed.
- Since QtQuick 1.1, a map of property values can be optionally passed to the method that applies values to the object's properties
- before its creation is finalised. This will avoid binding issues that can occur when the object is
- instantiated before property bindings have been set. For example:
+ As of QtQuick 1.1, this method accepts an optional \a properties argument that specifies a
+ map of initial property values for the created object. These values are applied before object
+ creation is finalized. (This is more efficient than setting property values after object creation,
+ particularly where large sets of property values are defined, and also allows property bindings
+ to be set up before the object is created.)
- \code component.createObject(parent, {"x": 100, "y": 100, "specialProperty": someObject}); \endcode
+ The \a properties argument is specified as a map of property-value items. For example, the code
+ below creates an object with initial \c x and \c y values of 100 and 200, respectively:
+
+ \qml
+ var component = Qt.createComponent("Button.qml");
+ if (component.status == Component.Ready)
+ component.createObject(parent, {"x": 100, "y": 100});
+ \endqml
Dynamically created instances can be deleted with the \c destroy() method.
See \l {Dynamic Object Management in QML} for more information.