diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-08-12 01:32:56 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-08-12 01:33:40 (GMT) |
commit | 59d36ea601aef6182cba0e0f5fc56cc102e29c59 (patch) | |
tree | 5d58b4d43f5ec46492b24d4b36e95f746cd38689 /src | |
parent | 0bbc19d5721c8c00f2b3c6cb28cca2d0adfda315 (diff) | |
download | Qt-59d36ea601aef6182cba0e0f5fc56cc102e29c59.zip Qt-59d36ea601aef6182cba0e0f5fc56cc102e29c59.tar.gz Qt-59d36ea601aef6182cba0e0f5fc56cc102e29c59.tar.bz2 |
Fix broken example code
Task-number: QTBUG-12839
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/qml/qdeclarativecontext.cpp | 13 |
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 |