summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlcomponent.cpp
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-06-09 02:46:10 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-06-09 02:46:10 (GMT)
commitdb4addcf3408140bb34fa8884c7192c1d9667be8 (patch)
tree3895f60a7c24d05082120c68d8d8fcd4972b2aaf /src/declarative/qml/qmlcomponent.cpp
parent991b41aa407b5a8740e6899a3efdc724276dcb95 (diff)
downloadQt-db4addcf3408140bb34fa8884c7192c1d9667be8.zip
Qt-db4addcf3408140bb34fa8884c7192c1d9667be8.tar.gz
Qt-db4addcf3408140bb34fa8884c7192c1d9667be8.tar.bz2
Add dynamic object creation from Script.
Can now create, inside script, objects from qml snippets and files. These objects can then be manipulated from script. Deleting these items is still being looked into.
Diffstat (limited to 'src/declarative/qml/qmlcomponent.cpp')
-rw-r--r--src/declarative/qml/qmlcomponent.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index 78137e8..267fba8 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -387,6 +387,24 @@ QmlComponent::QmlComponent(QmlComponentPrivate &dd, QObject *parent)
}
/*!
+ Create a script object instance from this component. Returns a null
+ script object if creation failed. It will create the instance in the
+ engine's \l {QmlEngine::rootContext()}{root context}.
+
+ Similar to QmlComponent::create(), but creates an object suitable
+ for usage within scripts.
+*/
+QScriptValue QmlComponent::createObject()
+{
+ Q_D(QmlComponent);
+ QObject* ret = create();
+ if(ret)
+ return QmlEngine::qmlScriptObject(ret, d->engine);
+ else
+ return d->engine->scriptEngine()->nullValue();
+}
+
+/*!
Create an object instance from this component. Returns 0 if creation
failed. \a context specifies the context within which to create the object
instance.