diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-07-16 08:11:36 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-07-16 08:12:18 (GMT) |
commit | 1ea53e6055a7c4e9677a5003725785ad503bb242 (patch) | |
tree | a44d37e563d29a1f620c7c100e1a398d64257a34 /doc/src/declarative/qdeclarativemodels.qdoc | |
parent | ae39a510f86fd13d6d41bc85d4f5c243eca45eab (diff) | |
download | Qt-1ea53e6055a7c4e9677a5003725785ad503bb242.zip Qt-1ea53e6055a7c4e9677a5003725785ad503bb242.tar.gz Qt-1ea53e6055a7c4e9677a5003725785ad503bb242.tar.bz2 |
fixes, improvements for various docs and example code
Diffstat (limited to 'doc/src/declarative/qdeclarativemodels.qdoc')
-rw-r--r-- | doc/src/declarative/qdeclarativemodels.qdoc | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/doc/src/declarative/qdeclarativemodels.qdoc b/doc/src/declarative/qdeclarativemodels.qdoc index b44e6f2..e02575d 100644 --- a/doc/src/declarative/qdeclarativemodels.qdoc +++ b/doc/src/declarative/qdeclarativemodels.qdoc @@ -208,7 +208,10 @@ Models can be defined in C++ and then made available to QML. This is useful for exposing existing C++ data models or otherwise complex datasets to QML. A C++ model class can be defined as a QStringList, a QList<QObject*> or a -QAbstractItemModel. +QAbstractItemModel. The first two are useful for exposing simpler datasets, +while QAbstractItemModel provides a more flexible solution for more complex +models. + \section2 QStringList @@ -268,7 +271,10 @@ the model by calling QDeclarativeContext::setContextProperty() again. \section2 QAbstractItemModel -A model can be defined by subclassing QAbstractItemModel. +A model can be defined by subclassing QAbstractItemModel. This is the +best approach if you have a more complex model that cannot be supported +by the other approaches. A QAbstractItemModel can also automatically +notify a QML view when the model data has changed. The roles of a QAbstractItemModel subclass can be exposed to QML by calling QAbstractItemModel::setRoleNames(). The default role names set by Qt are: @@ -305,6 +311,12 @@ roles: \snippet examples/declarative/modelviews/abstractitemmodel/view.qml 0 +QML views are automatically updated when the model changes. Remember the model +must follow the standard rules for model changes and notify the view when +the model has changed by using QAbstractItemModel::dataChanged(), +QAbstractItemModel::beginInsertRows(), etc. See the \l {Model subclassing reference} for +more information. + The complete example is available in Qt's \l {declarative/modelviews/abstractitemmodel}{examples/declarative/modelviews/abstractitemmodel} directory. QAbstractItemModel presents a hierarchy of tables, but the views currently provided by QML |