diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-16 03:35:55 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-07-16 03:35:55 (GMT) |
commit | 8d8566d061e26f18e1bde1255fdc1375035c8eaa (patch) | |
tree | 7467b6c7742a3d3828b918ecec8a73e1f7998791 /doc/src/declarative | |
parent | 6986f382c8d7b49342f47fe00445685945157187 (diff) | |
parent | 17e7b024ba01aba0e525f7fd03b9c5c0ed34e7c8 (diff) | |
download | Qt-8d8566d061e26f18e1bde1255fdc1375035c8eaa.zip Qt-8d8566d061e26f18e1bde1255fdc1375035c8eaa.tar.gz Qt-8d8566d061e26f18e1bde1255fdc1375035c8eaa.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: (104 commits)
Fixed tst_maketestselftest::tests_pro_files failure
remove nasty hack by using a stricter regexp (for language codes)
cosmetics: quote the dot in the regexp
remove dependency of ts targets on sub-tools
add commit-ts target to commit ts files without line number info
(re-)add 'untranslated' ts targets
more fine-grained ts targets
split qt_help out into an own ts target
Unbreak the Maemo 5 build after the Symbian fix
QNAM HTTP: Fix problem with cached files and metaDataChanged()
Add a testcase for QTBUG-11213 to prevent future regressions.
Autotest: reenable the NTLM proxy test on tst_QTcpSocket
Autotest: add a small, boring test for QAuthenticator
Add documentation for the QAuthenticator options.
Expose the QAuthenticator map of options in the API.
Add a QAuthenticatorPrivate parsing for the headers without QHttpResponseHeader
Revert BIC change "Build Qt with option -Zc:wchar_t under MSVC"
Fix for tst_qmdisubwindow::fixedMinMaxSize failure on Cocoa
Add unit tests for QMimeData.
fix qconfig.h reference for shadow builds
...
Diffstat (limited to 'doc/src/declarative')
-rw-r--r-- | doc/src/declarative/advtutorial.qdoc | 24 | ||||
-rw-r--r-- | doc/src/declarative/elements.qdoc | 2 | ||||
-rw-r--r-- | doc/src/declarative/qdeclarativeintro.qdoc | 2 | ||||
-rw-r--r-- | doc/src/declarative/qdeclarativemodels.qdoc | 73 |
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. + */ |