summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-08-12 01:32:56 (GMT)
committerJason McDonald <jason.mcdonald@nokia.com>2010-09-01 03:50:58 (GMT)
commit83cd3ec6422955276d6b9757722d17f366149fd6 (patch)
tree114d5a1f4a6d3c5bda2d2d04dc1bf51460e3eb50 /src/declarative
parentde18237aa865dccab424ea0bec7516065c5831ec (diff)
downloadQt-83cd3ec6422955276d6b9757722d17f366149fd6.zip
Qt-83cd3ec6422955276d6b9757722d17f366149fd6.tar.gz
Qt-83cd3ec6422955276d6b9757722d17f366149fd6.tar.bz2
Fix broken example code
Task-number: QTBUG-12839 (cherry picked from commit 59d36ea601aef6182cba0e0f5fc56cc102e29c59)
Diffstat (limited to 'src/declarative')
-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