summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/declarative/qml/qmlcomponent.cpp15
-rw-r--r--src/declarative/qml/qmlcomponent.h2
2 files changed, 17 insertions, 0 deletions
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index 0c85574..12fb120 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -385,6 +385,21 @@ void QmlComponent::setData(const QByteArray &data, const QUrl &url)
}
/*!
+Returns the QmlContext the component was created in. This is only
+valid for components created directly from QML.
+*/
+QmlContext *QmlComponent::creationContext() const
+{
+ Q_D(const QmlComponent);
+
+ QmlDeclarativeData *ddata = QmlDeclarativeData::get(this);
+ if (ddata)
+ return ddata->context;
+ else
+ return 0;
+}
+
+/*!
Load the QmlComponent from the provided \a url.
*/
void QmlComponent::loadUrl(const QUrl &url)
diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h
index 7470f31..a72aa4e 100644
--- a/src/declarative/qml/qmlcomponent.h
+++ b/src/declarative/qml/qmlcomponent.h
@@ -96,6 +96,8 @@ public:
void loadUrl(const QUrl &url);
void setData(const QByteArray &, const QUrl &baseUrl);
+ QmlContext *creationContext() const;
+
static QmlComponentAttached *qmlAttachedProperties(QObject *);
Q_SIGNALS: