summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/qdeclarativecontext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml/qdeclarativecontext.cpp')
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index 3d25291..a58dc6c 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -80,10 +80,12 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate()
\code
QDeclarativeEngine engine;
+ QStringListModel modelData;
QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
- context->setContextProperty("myModel", modelData);
+ context->setContextProperty("myModel", &modelData);
- QDeclarativeComponent component(&engine, "ListView { model=myModel }");
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.7\nListView { model: myModel }", QUrl());
component.create(context);
\endcode
@@ -104,12 +106,13 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate()
...
};
- MyDataSet *myDataSet = new MyDataSet;
+ MyDataSet myDataSet;
QDeclarativeEngine engine;
QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
- context->setContextObject(myDataSet);
+ context->setContextObject(&myDataSet);
- QDeclarativeComponent component(&engine, "ListView { model=myModel }");
+ QDeclarativeComponent component(&engine);
+ component.setData("import Qt 4.7\nListView { model: myModel }", QUrl());
component.create(context);
\endcode