summaryrefslogtreecommitdiffstats
path: root/src/declarative/util
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-08-09 08:26:47 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-08-09 08:26:47 (GMT)
commitcfe96b7c99cb12a666111c7861aba74d535adc89 (patch)
treeeda2c872b4446b8b4796162ea46c86a4ba171cc9 /src/declarative/util
parent86eec3f6f98b387bf6a815c1a8e916965928b317 (diff)
parent1d09376c4eec88ba94f00a4b045fc425c5f51346 (diff)
downloadQt-cfe96b7c99cb12a666111c7861aba74d535adc89.zip
Qt-cfe96b7c99cb12a666111c7861aba74d535adc89.tar.gz
Qt-cfe96b7c99cb12a666111c7861aba74d535adc89.tar.bz2
Merge remote branch 'origin/4.7' into oslo-staging-2/4.7
Conflicts: doc/src/index.qdoc src/dbus/qdbusconnection.cpp src/gui/s60framework/qs60mainapplication.cpp src/gui/s60framework/qs60mainappui.cpp src/network/access/qnetworkrequest.cpp src/network/bearer/qnetworkconfiguration.h
Diffstat (limited to 'src/declarative/util')
-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