diff options
author | Bea Lam <bea.lam@nokia.com> | 2010-07-06 05:30:33 (GMT) |
---|---|---|
committer | Bea Lam <bea.lam@nokia.com> | 2010-07-06 05:30:33 (GMT) |
commit | c9d487b6ed3ac9bb666c2a1fe08252f3c6dcb455 (patch) | |
tree | 68ca42e8c1bbfcf99e6db77be213688d437feeba /src/declarative/qml/qdeclarativecomponent.cpp | |
parent | 6b2ec2ab8df94233d6ba7960d5bfb3c7461b76ec (diff) | |
download | Qt-c9d487b6ed3ac9bb666c2a1fe08252f3c6dcb455.zip Qt-c9d487b6ed3ac9bb666c2a1fe08252f3c6dcb455.tar.gz Qt-c9d487b6ed3ac9bb666c2a1fe08252f3c6dcb455.tar.bz2 |
doc improvements
Diffstat (limited to 'src/declarative/qml/qdeclarativecomponent.cpp')
-rw-r--r-- | src/declarative/qml/qdeclarativecomponent.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 9d3032c..6d15278 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -70,6 +70,36 @@ class QByteArray; \since 4.7 \brief The QDeclarativeComponent class encapsulates a QML component description. \mainclass + + Components are reusable, encapsulated QML elements with well-defined interfaces. + They are often defined in \l {qdeclarativedocuments.html}{Component Files}. + + A QDeclarativeComponent instance can be created from a QML file. + For example, if there is a \c main.qml file like this: + + \qml + import Qt 4.7 + + Item { + width: 200 + height: 200 + } + \endqml + + The following code loads this QML file as a component, creates an instance of + this component using create(), and then queries the \l Item's \l {Item::}{width} + value: + + \code + QDeclarativeEngine *engine = new QDeclarativeEngine; + QDeclarativeComponent component(engine, QUrl::fromLocalFile("main.qml")); + + QObject *myObject = component.create(); + QDeclarativeItem *item = qobject_cast<QDeclarativeItem*>(myObject); + int width = item->width(); + \endcode + + \sa {Using QML in C++ Applications} */ /*! |