summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-07-29 03:13:56 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-07-29 03:13:56 (GMT)
commitd1e1f49ea0b742fd655112fdb30f5751e142a766 (patch)
tree627f51a48220ce488e2447bb63938c8fb30df94c /src/declarative/qml
parent24a4c2815d0dfed7ed925b22ab92b8b6aeb7924b (diff)
parent155f99502be75ff400bbae550328dbc79801d6c8 (diff)
downloadQt-d1e1f49ea0b742fd655112fdb30f5751e142a766.zip
Qt-d1e1f49ea0b742fd655112fdb30f5751e142a766.tar.gz
Qt-d1e1f49ea0b742fd655112fdb30f5751e142a766.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Remove warnings in photoviewer demo. Uncomment code accidentally removed with 1937adaab5861ced44813c6a4b0bff1c3750ecd3 Fix image source Don't emit movementEnded if mouse press is a continuation of a flick. Avoid binding loop warnings Append 'Example' to titles of example pages Improvements to Modules docs Component docs Fixes for Dynamic Object Management docs. Also adds links to Update Symbian emulator QtOpenVGu.def, QtNetworku.def, QtCoreu.def files for Qt 4.7 to be in sync between respective def files in Qt 4.6.3
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp33
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp27
-rw-r--r--src/declarative/qml/qdeclarativeextensionplugin.cpp6
3 files changed, 25 insertions, 41 deletions
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index 7bc6184..1d48b1a 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()}.
*/
/*!
@@ -609,6 +597,9 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
the \a parent value. Note that if the returned object is to be displayed, you
must provide a valid \a parent value or set the returned object's \l{Item::parent}{parent}
property, or else the object will not be visible.
+
+ Dynamically created instances can be deleted with the \c destroy() method.
+ See \l {Dynamic Object Management} for more information.
*/
/*!
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 346a2f4..8eb0939 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -1104,29 +1104,20 @@ QString QDeclarativeEnginePrivate::urlToLocalFileOrQrc(const QUrl& url)
\qmlmethod object Qt::createComponent(url)
Returns a \l Component object created using the QML file at the specified \a url,
-or \c null if there was an error in creating the component.
+or \c null if an empty string was given.
+
+The returned component's \l Component::status property indicates whether the
+component was successfully created. If the status is \c Component.Error,
+see \l Component::errorString() for an error description.
Call \l {Component::createObject()}{Component.createObject()} on the returned
component to create an object instance of the component.
-Here is an example. Notice it checks whether the component \l{Component::status}{status} is
-\c Component.Ready before calling \l {Component::createObject()}{createObject()}
-in case the QML file is loaded over a network and thus is not ready immediately.
-
-\snippet doc/src/snippets/declarative/componentCreation.js vars
-\codeline
-\snippet doc/src/snippets/declarative/componentCreation.js func
-\snippet doc/src/snippets/declarative/componentCreation.js remote
-\snippet doc/src/snippets/declarative/componentCreation.js func-end
-\codeline
-\snippet doc/src/snippets/declarative/componentCreation.js finishCreation
+For example:
-If you are certain the QML file to be loaded is a local file, you could omit the \c finishCreation()
-function and call \l {Component::createObject()}{createObject()} immediately:
+\snippet doc/src/snippets/declarative/createComponent-simple.qml 0
-\snippet doc/src/snippets/declarative/componentCreation.js func
-\snippet doc/src/snippets/declarative/componentCreation.js local
-\snippet doc/src/snippets/declarative/componentCreation.js func-end
+See \l {Dynamic Object Management} for more information on using this function.
To create a QML object from an arbitrary string of QML (instead of a file),
use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}.
@@ -1177,6 +1168,8 @@ Each object in this array has the members \c lineNumber, \c columnNumber, \c fil
Note that this function returns immediately, and therefore may not work if
the \a qml string loads new components (that is, external QML files that have not yet been loaded).
If this is the case, consider using \l{QML:Qt::createComponent()}{Qt.createComponent()} instead.
+
+See \l {Dynamic Object Management} for more information on using this function.
*/
QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine)
diff --git a/src/declarative/qml/qdeclarativeextensionplugin.cpp b/src/declarative/qml/qdeclarativeextensionplugin.cpp
index 448fde2..9b5eb61 100644
--- a/src/declarative/qml/qdeclarativeextensionplugin.cpp
+++ b/src/declarative/qml/qdeclarativeextensionplugin.cpp
@@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
\o Subclass QDeclarativeExtensionPlugin, implement registerTypes() method
to register types using qmlRegisterType(), and export the class using the Q_EXPORT_PLUGIN2() macro
\o Write an appropriate project file for the plugin
- \o Create a \l{The qmldir file}{qmldir file} to describe the plugin
+ \o Create a \l{Writing a qmldir file}{qmldir file} to describe the plugin
\endlist
QML extension plugins can be used to provide either application-specific or
@@ -79,7 +79,7 @@ QT_BEGIN_NAMESPACE
\dots
To make this class available as a QML type, create a plugin that registers
- this type using qmlRegisterType(). For this example the plugin
+ this type with a specific \l {QML Modules}{module} using qmlRegisterType(). For this example the plugin
module will be named \c com.nokia.TimeExample (as defined in the project
file further below).
@@ -104,7 +104,7 @@ QT_BEGIN_NAMESPACE
...
\endcode
- Finally, a \l{The qmldir file}{qmldir file} is required in the \c com/nokia/TimeExample directory
+ Finally, a \l{Writing a qmldir file}{qmldir file} is required in the \c com/nokia/TimeExample directory
that describes the plugin. This directory includes a \c Clock.qml file that
should be bundled with the plugin, so it needs to be specified in the \c qmldir
file: