summaryrefslogtreecommitdiffstats
path: root/doc/src/declarative
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-07-14 11:50:03 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-07-14 11:50:03 (GMT)
commit09503163c88d57b9b163530131c0ec0a1e4194fd (patch)
treeaa4cadf08f69929b66945648a43a4e18790ecffc /doc/src/declarative
parent5878027280de47e8b8fc72a4d0d48f5e5f6dc7db (diff)
parent56e24c99ee7a1b5b127b93cbab98f88e008ec9b8 (diff)
downloadQt-09503163c88d57b9b163530131c0ec0a1e4194fd.zip
Qt-09503163c88d57b9b163530131c0ec0a1e4194fd.tar.gz
Qt-09503163c88d57b9b163530131c0ec0a1e4194fd.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: (83 commits) Crash while runnig tst_QMdiSubWindow::emittingOfSignals test on Cocoa fix qconfig.h aliased header creation fix warning directive on gnuc qdoc: Removed navigation arrow that was causing display problems. Silence warning when building with MSVC 2005 Fix an Assert in QTextTable Revert "Fix an Assert in QTextTable" Attempt to fix build failure with msvc200{5,8} on Windows XP. fix macx not having UNICODE in DEFINES any more doc: Fixed several qdoc warnings. Fix an Assert in QTextTable doc: Fixed several qdoc warnings. QSslSocket: Improve error handling qdoc: Fixed several <div> elements that had the "/>" ending. QSslSocket: fix documentation for QSslSocket::setPeerVerifyMode() qdoc: Fixed breadcrumbs for QML examples. remove redundand translations project files make projects lupdate-friendly Timing fix for slow devices. QNAM: Add future enum attribute for Zerocopy QNAM ...
Diffstat (limited to 'doc/src/declarative')
-rw-r--r--doc/src/declarative/advtutorial.qdoc24
-rw-r--r--doc/src/declarative/elements.qdoc2
-rw-r--r--doc/src/declarative/qdeclarativeintro.qdoc2
-rw-r--r--doc/src/declarative/qdeclarativemodels.qdoc73
4 files changed, 91 insertions, 10 deletions
diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc
index afedb44..1341bbb 100644
--- a/doc/src/declarative/advtutorial.qdoc
+++ b/doc/src/declarative/advtutorial.qdoc
@@ -164,14 +164,22 @@ The \c createBlock() function creates a block from the \c Block.qml file
and moves the new block to its position on the game canvas. This involves several steps:
\list
-\o \l {QML:Qt::createComponent()}{Qt.createComponent()} is called to generate an element from \c Block.qml.
- If the component is ready, we can call \c createObject() to create an instance of the \c Block item.
-\o If \c createObject() returned null (i.e. if there was an error while
- loading the object), print the error information.
-\o Place the block in its position on the board and set its width and height.
- Also, store it in the blocks array for future reference.
-\o Finally, print error information to the console if the component could not be
- loaded for some reason (for example, if the file is missing).
+
+\o \l {QML:Qt::createComponent()}{Qt.createComponent()} is called to
+ generate an element from \c Block.qml. If the component is ready,
+ we can call \c createObject() to create an instance of the \c Block
+ item.
+
+\o If \c createObject() returned null (i.e. if there was an error
+ while loading the object), print the error information.
+
+\o Place the block in its position on the board and set its width and
+ height. Also, store it in the blocks array for future reference.
+
+\o Finally, print error information to the console if the component
+ could not be loaded for some reason (for example, if the file is
+ missing).
+
\endlist
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc
index 0edd242..c2930b3 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -113,7 +113,7 @@ The following table lists the QML elements provided by the \l {QtDeclarative}{Qt
\row \o \l {Connections} \o Explicitly connects signals and signal handlers
\row \o \l {Component} \o Encapsulate QML items as a component
\row \o \l {Timer} \o Provides timed triggers
-\row \o \l {QtObject} \o Basic element containing only the objectName property
+\row \o \l {QML:QtObject} {QtObject} \o Basic element containing only the objectName property
\row \o \l {WorkerScript} \o Enables the use of threads in QML
\row \o \l {Loader} \o Controls the loading of items or components
\row \o \l {Repeater} \o Uses a model to create multiples of components
diff --git a/doc/src/declarative/qdeclarativeintro.qdoc b/doc/src/declarative/qdeclarativeintro.qdoc
index 9126a79..3f1b184 100644
--- a/doc/src/declarative/qdeclarativeintro.qdoc
+++ b/doc/src/declarative/qdeclarativeintro.qdoc
@@ -314,7 +314,7 @@ Item {
\section2 Signal Handlers
-Signal handlers allow actions to be taken in reponse to an event. For instance,
+Signal handlers allow actions to be taken in response to an event. For instance,
the \l MouseArea element has signal handlers to handle mouse press, release
and click:
diff --git a/doc/src/declarative/qdeclarativemodels.qdoc b/doc/src/declarative/qdeclarativemodels.qdoc
index b44e6f2..a2f4d3a 100644
--- a/doc/src/declarative/qdeclarativemodels.qdoc
+++ b/doc/src/declarative/qdeclarativemodels.qdoc
@@ -429,4 +429,77 @@ Rectangle {
}
\endcode
+\section1 Accessing Views and Models from Delegates
+
+You can access the view for which a delegate is used, and its
+properties, by using ListView.view in a delegate on a ListView, or
+GridView.view in a delegate on a GridView, etc. In particular, you can
+access the model and its properties by using ListView.view.model.
+
+This is useful when you want to use the same delegate for a number of
+views, for example, but you want decorations or other features to be
+different for each view, and you would like these different settings to
+be properties of each of the views. Similarly, it might be of interest
+to access or show some properties of the model.
+
+In the following example, the delegate shows the property \e{language}
+of the model, and the color of one of the fields depends on the
+property \e{fruit_color} of the view.
+
+\code
+Rectangle {
+ width: 200; height: 200
+
+ ListModel {
+ id: fruitModel
+ property string language: "en"
+ ListElement {
+ name: "Apple"
+ cost: 2.45
+ }
+ ListElement {
+ name: "Orange"
+ cost: 3.25
+ }
+ ListElement {
+ name: "Banana"
+ cost: 1.95
+ }
+ }
+
+ Component {
+ id: fruitDelegate
+ Row {
+ Text { text: " Fruit: " + name; color: ListView.view.fruit_color }
+ Text { text: " Cost: $" + cost }
+ Text { text: " Language: " + ListView.view.model.language }
+ }
+ }
+
+ ListView {
+ property color fruit_color: "green"
+ model: fruitModel
+ delegate: fruitDelegate
+ anchors.fill: parent
+ }
+}
+\endcode
+
+Another important case is when some action (e.g. mouse click) in the
+delegate should update data in the model. In this case you can define
+a function in the model, e.g.:
+
+\code
+ setData(int row, const QString & field_name, QVariant new_value),
+\endcode
+
+...and call it from the delegate using:
+
+\code
+ ListView.view.model.setData(index, field, value)
+\endcode
+
+...assuming that \e{field} holds the name of the field which should be
+updated, and that \e{value} holds the new value.
+
*/