summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qmlcomponent.cpp
diff options
context:
space:
mode:
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.