summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2010-05-24 10:02:57 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2010-05-24 10:46:57 (GMT)
commit1079096a57112d9615812771adba18d2e9297320 (patch)
tree9c1fbdf2475e831fc9cce597586f37836589f60b /src
parent4c975ee19b9671fbf76b546fc8ca2eff5bc69303 (diff)
downloadQt-1079096a57112d9615812771adba18d2e9297320.zip
Qt-1079096a57112d9615812771adba18d2e9297320.tar.gz
Qt-1079096a57112d9615812771adba18d2e9297320.tar.bz2
Added autotest for Component.createObject() without Qt.createComponent()
Also augmented the docs for both functions a little. Task-number: QTBUG-10926
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp10
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp4
2 files changed, 9 insertions, 5 deletions
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index 3b782e7..7aa17e8 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -549,15 +549,19 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
Returns an object instance from this component, or null if object creation fails.
The object will be created in the same context as the one in which the component
- was created.
+ was created. This function will always return null when called on components
+ which were not created in QML.
Note that if the returned object is to be displayed, its \c parent must be set to
- an existing item in a scene, or else the object will not be visible.
+ an existing item in a scene, or else the object will not be visible. The parent
+ argument is required to help you avoid this, you must explicitly pass in null if
+ you wish to create an object without setting a parent.
*/
/*!
\internal
- A version of create which returns a scriptObject, for use in script
+ A version of create which returns a scriptObject, for use in script.
+ This function will only work on components created in QML.
Sets graphics object parent because forgetting to do this is a frequent
and serious problem.
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index df9aa59..a7384a9 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -1049,9 +1049,9 @@ If you are certain the files will be local, you could simplify to:
\snippet doc/src/snippets/declarative/componentCreation.js 2
-The methods and properties of the Component element are defined in its own
+The methods and properties of the \l {Component} element are defined in its own
page, but when using it dynamically only two methods are usually used.
-\c Component.createObject() returns the created object or \c null if there is an error.
+ \l {Component::createObject()}{Component.createObject()} returns the created object or \c null if there is an error.
If there is an error, \l {Component::errorString()}{Component.errorString()} describes
the error that occurred. Note that createObject() takes exactly one argument, which is set
to the parent of the created object. Graphical objects without a parent will not appear