aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/qml/qqmlcontext.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp
index 2e5b18cc62..5821aca595 100644
--- a/src/qml/qml/qqmlcontext.cpp
+++ b/src/qml/qml/qqmlcontext.cpp
@@ -76,11 +76,11 @@ QT_BEGIN_NAMESPACE
context->setContextProperty("myModel", &modelData);
QQmlComponent component(&engine);
- component.setData("import QtQuick 2.0\nListView { model: myModel }", QUrl());
+ component.setData("import QtQuick 2.0; ListView { model: myModel }", QUrl());
QObject *window = component.create(context);
\endcode
- Note it is the responsibility of the creator to delete any QQmlContext it
+ \note It is the responsibility of the creator to delete any QQmlContext it
constructs. If the \c context object in the example is no longer needed when the
\c window component instance is destroyed, the \c context must be destroyed explicitly.
The simplest way to ensure this is to set \c window as the parent of \c context.
@@ -96,10 +96,10 @@ QT_BEGIN_NAMESPACE
object.
\code
- class MyDataSet : ... {
- ...
+ class MyDataSet : public QObject {
+ // ...
Q_PROPERTY(QAbstractItemModel *myModel READ model NOTIFY modelChanged)
- ...
+ // ...
};
MyDataSet myDataSet;
@@ -108,7 +108,7 @@ QT_BEGIN_NAMESPACE
context->setContextObject(&myDataSet);
QQmlComponent component(&engine);
- component.setData("import QtQuick 2.0\nListView { model: myModel }", QUrl());
+ component.setData("import QtQuick 2.0; ListView { model: myModel }", QUrl());
component.create(context);
\endcode
@@ -132,10 +132,10 @@ QT_BEGIN_NAMESPACE
QQmlContext *context1 = new QQmlContext(engine.rootContext());
QQmlContext *context2 = new QQmlContext(context1);
- context1->setContextProperty("a", 12);
- context1->setContextProperty("b", 12);
+ context1->setContextProperty("a", 9001);
+ context1->setContextProperty("b", 9001);
- context2->setContextProperty("b", 15);
+ context2->setContextProperty("b", 42);
\endcode
While QML objects instantiated in a context are not strictly owned by that