summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-08-06 06:32:19 (GMT)
committerToby Tomkins <toby.tomkins@nokia.com>2010-08-08 11:13:14 (GMT)
commitced01d71bd68e679a4563ed123110528775aac04 (patch)
tree72dfbadb0c6dec8f60e113bad88f96da2b576a9c
parente970b655bd11c0b3924cfc5d37b01357f91b693c (diff)
downloadQt-ced01d71bd68e679a4563ed123110528775aac04.zip
Qt-ced01d71bd68e679a4563ed123110528775aac04.tar.gz
Qt-ced01d71bd68e679a4563ed123110528775aac04.tar.bz2
Fix broken example code
Task-number: QTBUG-12705 (cherry picked from commit 59e3430662cfdc3820115a2ff4c0b44829b3d1d4)
-rw-r--r--src/declarative/util/qdeclarativepropertymap.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/declarative/util/qdeclarativepropertymap.cpp b/src/declarative/util/qdeclarativepropertymap.cpp
index 919727f..6b43040 100644
--- a/src/declarative/util/qdeclarativepropertymap.cpp
+++ b/src/declarative/util/qdeclarativepropertymap.cpp
@@ -104,22 +104,25 @@ void QDeclarativePropertyMapMetaObject::propertyCreated(int, QMetaPropertyBuilde
The following example shows how you might declare data in C++ and then
access it in QML.
- Setup in C++:
+ In the C++ file:
\code
- //create our data
+ // create our data
QDeclarativePropertyMap ownerData;
ownerData.insert("name", QVariant(QString("John Smith")));
ownerData.insert("phone", QVariant(QString("555-5555")));
- //expose it to the UI layer
- QDeclarativeContext *ctxt = view->rootContext();
- ctxt->setProperty("owner", &data);
+ // expose it to the UI layer
+ QDeclarativeView view;
+ QDeclarativeContext *ctxt = view.rootContext();
+ ctxt->setContextProperty("owner", &ownerData);
+
+ view.setSource(QUrl::fromLocalFile("main.qml"));
+ view.show();
\endcode
- Then, in QML:
+ Then, in \c main.qml:
\code
- Text { text: owner.name }
- Text { text: owner.phone }
+ Text { text: owner.name + " " + owner.phone }
\endcode
The binding is dynamic - whenever a key's value is updated, anything bound to that