diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-07-28 16:54:38 +1000 |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-07-29 10:51:26 +1000 |
commit | dd871bf6208821ab9852680a338133accbfdedd7 (patch) | |
tree | 052489175bc6d282f55c2d8ad8d9d9a93280029e /src/declarative/qml/qdeclarativecomponent.cpp | |
parent | ceeb0fc0327c99de55d4dd6114908ec389dc58eb (diff) |
Component docs
Task-number: QTBUG-12447
Diffstat (limited to 'src/declarative/qml/qdeclarativecomponent.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativecomponent.cpp | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index e8e237fd73..1d48b1ab2a 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -115,26 +115,10 @@ class QByteArray; a small component within a QML file, or for defining a component that logically belongs with other QML components within a file. - For example, here is a component that is used by multiple \l Loader objects: + For example, here is a component that is used by multiple \l Loader objects. + It contains a top level \l Rectangle item: - \qml - Item { - width: 100; height: 100 - - Component { - id: redSquare - - Rectangle { - color: "red" - width: 10 - height: 10 - } - } - - Loader { sourceComponent: redSquare } - Loader { sourceComponent: redSquare; x: 20 } - } - \endqml + \snippet doc/src/snippets/declarative/component.qml 0 Notice that while a \l Rectangle by itself would be automatically rendered and displayed, this is not the case for the above rectangle @@ -143,12 +127,16 @@ class QByteArray; file, and is not loaded until requested (in this case, by the two \l Loader objects). + A Component cannot contain anything other + than an \c id and a single top level item. While the \c id is optional, + the top level item is not; you cannot define an empty component. + The Component element is commonly used to provide graphical components for views. For example, the ListView::delegate property requires a Component to specify how each list item is to be displayed. - Component objects can also be dynamically generated using - \l{Qt::createComponent()}{Qt.createComponent()}. + Component objects can also be dynamically created using + \l{QML:Qt::createComponent()}{Qt.createComponent()}. */ /*! |