summaryrefslogtreecommitdiffstats
path: root/doc/src
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/declarative/propertybinding.qdoc2
-rw-r--r--doc/src/declarative/qmlformat.qdoc350
-rw-r--r--doc/src/declarative/qmlmodels.qdoc45
-rw-r--r--doc/src/declarative/qtbinding.qdoc236
-rw-r--r--doc/src/declarative/qtdeclarative.qdoc11
-rw-r--r--doc/src/snippets/declarative/listview/highlight.qml12
6 files changed, 200 insertions, 456 deletions
diff --git a/doc/src/declarative/propertybinding.qdoc b/doc/src/declarative/propertybinding.qdoc
index 50cbf2d..2b8a58c 100644
--- a/doc/src/declarative/propertybinding.qdoc
+++ b/doc/src/declarative/propertybinding.qdoc
@@ -97,6 +97,6 @@ The implicit binding syntax shown previously is easy to use and works perfectly
of bindings. In some advanced cases, it is necessary to create bindings explicitly using the
\l Binding element.
-One such example is included in the \l {Passing Data Between C++ and QML} documentation.
+XXX - need an example
*/
diff --git a/doc/src/declarative/qmlformat.qdoc b/doc/src/declarative/qmlformat.qdoc
deleted file mode 100644
index 72bbe40..0000000
--- a/doc/src/declarative/qmlformat.qdoc
+++ /dev/null
@@ -1,350 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Qt Software Information (qt-info@nokia.com)
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at qt-sales@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
-\page qmlformat.html
-\title QML Format Reference
-
-\tableofcontents
-
-\section1 Overview
-
-QML is an extension to \l {http://www.ecma-international.org/publications/standards/Ecma-262.htm}
-{ECMAScript}. QML adds a mechanism for declaratively building a tree of objects, improved
-integration between ECMAScript and Qt's existing QObject based type system, and support for
-transparently maintained property value bindings between ECMAScript expressions and QObject
-properties.
-
-Much of a QML file consists of valid ECMAScript \e {Statement}s. Except where constraints imposed
-by ECMAScript, C++ or QObject prevented it, the syntactic extensions introduced by QML are designed
-to look similar and fit well with existing ECMAScript syntax and concepts.
-
-\section1 QML engine
-
-The \l {QmlEngine}{QML engine} executes a \l {QmlComponent}{QML document} in a
-\l {QmlContext}{QML context} to produce a \l {QObject}{QML object}. A single QML
-document may be executed in one or many contexts to produce many QML objects. A single
-QML document may be executed many times in the same context to produce many QML objects.
-
-The QML engine provides the environment in which QML documents, contexts and objects
-exist. It must exist before any of these structures can be created. If the engine is removed,
-existing documents, contexts and objects are invalidated, but not destroyed. An invalid
-
-\list
-\i \e {QML document} can no longer be used to create QML objects.
-\i \e {QML context} can no longer host QML objects, new context properties cannot be added
-and existing context properties cannot be modified.
-\i \e {QML object} will no longer evaluate bindings or scripts.
-\endlist
-
-A QML document is a block of QML source code. QML documents generally correspond to files stored
-on a disk or network resource, but can be constructed directly from text data. Syntactically a QML
-document is self contained; QML does \bold {not} have a preprocessor that modifies the document
-before presentation to the compiler. Type references within a QML document are resolved based
-exclusively on the import statements present in the document.
-
-A simple QML document looks like this:
-
-\table
-\row
-\o
-\code
-import Qt 4.6
-
-Rectangle {
- id: myRect
- width: 100; height: 100
- color: background
-}
-\endcode
-\endtable
-
-To instantiate a QML object, a QML document is executed in a QML context. QML contexts are used by
-programmers to pass data to a QML document. QML documents may include property bindings or
-ECMAScript blocks that can contain variable references that need to be resolved. Each property
-binding and ECMAScript block has an associated QML context that is used to resolve these references
-that is determined by the QML context in which the document is executed. The example document above
-contains one variable reference, \c background.
-
-Each QML context defines a scope for variable resolution and each may define local, named context
-properties. A QML context may also have a \l {QmlContext::addDefaultObject()}{default object},
-which is an object whose properties are searched \e after the context properties when resolving a
-variable name. QML contexts form a tree, starting from a root context that is provided by the QML
-engine. When resolving variable references, the QML contexts are searched starting from the
-QML objects containing context upwards towards the root context.
-
-Consider the following QML context tree. If the example QML document is executed in \c Context1,
-the \c background variable will resolve to \c Context1's context property. If the document is
-executed in \c Context2, the \c background variable will resolve to the root context's context
-property.
-
-\image qml-context-tree.png
-
-While QML contexts can be created explicitly by the programmer to pass data into QML objects,
-the QML engine also creates a new implicit QML context for every object it instantiates.
-Property bindings and ECMAScript blocks in the document are associated with this QML engine
-created context. Object ids that are defined in the document are added as context properties, and
-their value is set to reference the appropriate object, and the instantiated QML object is set as
-the context's default object. The following diagram shows the result of executing a simple QML
-document.
-
-\image qml-context-object.png
-
-The blue rectangle in the diagram represents a property binding. Associated with each property
-binding is the QML context to which it belongs, the object property to which it is bound and a
-\e {scope object}. The scope object is usually, but not always, the object to which the bound
-property belongs. The context properties, context default objects and the scope object are all
-involved when resolving a variable name in a binding. The following pseudo code describes the
-algorithm used:
-
-\table
-\row
-\o
-\code
-if (scopeObject.hasProperty(name))
- return scopeObject.property(name)
-
-foreach (context in contextChain) {
- if (context.hasContextProperty(name)
- return context.contextProperty(name)
-
- if (context.defaultObject.hasProperty(name))
- return context.defaultObject.property(name)
-}
-\endcode
-\endtable
-
-QML supports two categories of types: \e builtin types and \e composite types. Builtin types are
-those written in C++ and registered with the QML engine. Builtin types form the most basic
-building blocks of QML. Composite types are constructed by composing other builtin or composite
-types, property bindings and ECMAScript blocks together into a brand new type using the QML
-language. Using a composite type is identical to using a builtin type.
-
-For example, Qt 4.6 includes a builtin type called \c Image that shows a bitmap image. The
-\c Image type has \c width and \c height properties that control the size of the displayed image.
-A simple composite type, that will be called \c SquareImage can be built that adds a \c size
-property that sets both the width and the height.
-
-\table
-\row
-\o
-\code
-import Qt 4.6
-Image {
- property int size
- width: size
- height: size
-}
-\endcode
-\endtable
-
-To the QML engine, a composite type is just another QML document. When a composite type is
-used the engine instantiates it just as it would any other document - by creating a new implicit
-QML context and the object tree described by the document. The diagram below shows the
-\c SquareImage composite type used from within another QML document. When instantiated, the
-\c SquareImage object is created in its own QML context. Any property bindings specified in the
-\c SquareImage composite type document are associated with this context. Property bindings created
-in the outer document, however, are associated with its context, even those that are applied to the
-created \c SquareImage object. That is, the \c size, \c source, \c width and \c height property
-bindings all share a common \e {scope object}, but are owned by two different QML contexts. The
-difference in containing context results in the \c Root variable resolving differently in the
-different property bindings.
-
-\image qml-context.png
-
-\section1 Syntax
-
-\section2 Encoding
-
-QML files are always encoded in UTF-8 format.
-
-\section2 Commenting
-
-The commenting rules in QML are the same as for ECMAScript. Both \e {MultiLineComment} blocks and \e {SingleLineComment}'s are supported.
-
-\section2 QML Document
-
-\section3 Syntax
-
-\e {QMLDocument} \bold {:}
-
-\quotation
-\e {QMLImportList} \sub {opt} \e {QMLObjectDefinition}
-\endquotation
-
-\e {QMLImportList} \bold {:}
-\quotation
-\e {QMLImportStatement} \e {QMLImportList} \sub {opt}
-\endquotation
-
-\e {QMLImportStatement} \bold {:}
-
-\quotation
-\bold {import} \e {StringLiteral}
-
-\bold {import} \e {StringLiteral} \e {QMLVersionNumber}
-
-\bold {import} \e {QMLNamespaceName} \e {QMLVersionNumber}
-
-\bold {import} \e {StringLiteral} \bold {as} \e {QMLNamespacePrefix}
-
-\bold {import} \e {StringLiteral} \e {QMLVersionNumber} \bold {as} \e {QMLNamespacePrefix}
-
-\bold {import} \e {QMLNamespaceName} \e {QMLVersionNumber} \bold {as} \e {QMLNamespacePrefix}
-\endquotation
-
-\e {QMLNamespaceName} \bold {:}
-\quotation
-\e {QMLQualifiedId}
-\endquotation
-
-\e {QMLVersionNumber} \bold {:}
-\quotation
-\e {DecimalLiteral} \bold {but not} with \e {ExponentPart}
-\endquotation
-
-\section3 Semantics
-
-The \e {QMLImportList} is used to statically resolve type references used within the enclosing
-QML document.
-
-An import statement is used to bring a set of types into scope for a QML document.
-
-\section2 Object Definition
-
-\section3 Syntax
-
-\e {QMLObjectDefinition} \bold {:}
-\quotation
-\e {QMLQualifiedId} \bold {\{} \e {QMLObjectMemberList} \bold {\}}
-\endquotation
-
-\e {QMLObjectMemberList} \bold {:}
-\quotation
-\e {QMLObjectMember} \e {QMLObjectMemberList} \sub {opt}
-\endquotation
-
-\e {QMLObjectMember} \bold {:}
-\quotation
-\e {QMLMemberAssignment}
-
-\e {QMLObjectDefinition}
-
-\e {QMLObjectExtensionDefinition}
-\endquotation
-
-\e {QMLMemberAssignmentList} \bold {:}
-\quotation
-\e {QMLMemberAssignment} \e {QMLMemberAssignmentList} \sub {opt}
-\endquotation
-
-\e {QMLMemberAssignment} \bold {:}
-\quotation
-
-\e {QMLQualifiedId} \bold {:} \e {Literal} \bold {but not} \e {NullLiteral}
-
-\e {QMLQualifiedId} \bold {:} \e {QMLObjectDefinition}
-
-\e {QMLQualifiedId} \bold {:} \e {QMLObjectDefinitionArray}
-
-\e {QMLQualifiedId} \bold {:} \e {QMLBindingExpression}
-
-\e {QMLQualifiedId} \bold {\{} \e {QMLMemberAssignmentList} \bold {\}}
-
-\endquotation
-
-\section3 Semantics
-
-\section2 Object Extension
-
-\section3 Syntax
-
-\e {QMLObjectExtensionDefinition} \bold {:}
-\quotation
-\e {QMLObjectPropertyDefinition}
-
-\e {QMLObjectSignalDefinition}
-
-\e {QMLObjectMethodDefinition}
-\endquotation
-
-\e {QMLObjectPropertyDefinition} \bold {:}
-\quotation
-\bold {property} \e {QmlObjectPropertyType} \e {QMLMemberIdentifier}
-
-\bold {default} \bold {property} \e {QmlObjectPropertyType} \e {QMLMemberIdentifier}
-
-\bold {property} \e {QmlObjectPropertyType} \e {QMLMemberIdentifier} \bold {:} \e {Literal} \bold {but not} \e {NullLiteral}
-
-\bold {property} \e {QmlObjectPropertyType} \e {QMLMemberIdentifier} \bold {:} \e {QmlBindingExpression}
-
-\bold {default} \bold {property} \e {QmlObjectPropertyType} \e {QMLMemberIdentifier} \bold {:} \e {Literal} \bold {but not} \e {NullLiteral}
-
-\bold {default} \bold {property} \e {QmlObjectPropertyType} \e {QMLMemberIdentifier} \bold {:} \e {QmlBindingExpression}
-\endquotation
-
-\e {QMLObjectPropertyType} \bold {:: one of}
-\quotation
-\bold {int} \bold {bool} \bold {double} \bold {real} \bold {string} \bold {url} \bold {color} \bold {date} \bold {var} \bold {variant} \bold {alias}
-\endquotation
-
-\e {QMLObjectSignalDefinition} \bold {:}
-\quotation
-\bold {signal} \e {QMLMemberIdentifier}
-
-\bold {signal} \e {QMLMemberIdentifier} \bold {(} QMLMemberTypedParameterList \bold {)}
-\endquotation
-
-\e {QMLObjectMethodDefinition} \bold {:}
-\quotation
-\e {FunctionDeclaration} \bold {but not} \e {Identifier} \sub {opt}
-\endquotation
-\section3 Semantics
-
-\section2 Binding Expression
-
-\section3 Syntax
-
-\e {QMLBindingExpression} \bold {:}
-
-\section3 Semantics
-
-*/
diff --git a/doc/src/declarative/qmlmodels.qdoc b/doc/src/declarative/qmlmodels.qdoc
index 6ebb734..45df29b 100644
--- a/doc/src/declarative/qmlmodels.qdoc
+++ b/doc/src/declarative/qmlmodels.qdoc
@@ -50,12 +50,18 @@ creates an instance for each item in the model. Models may be static, or
have items modified, inserted, removed or moved dynamically.
Data is provided to the delegate via named data roles which the
-delegate may bind to. A special \e index role containing the
-index of the item in the model is also available. Models that do
-not have named roles will have the data provided via the \e modelData
-role. The \e modelData role is also provided for Models that have
-only one role. In this case the \e modelData role contains the same
-data as the named role.
+delegate may bind to. The roles are exposed as properties of the
+\model property, though this property is set as a default property
+of the delegate so, unless there is a naming clash with a
+property in the delegate, the roles are usually accessed unqualified.
+
+A special \e index role containing the index of the item in the model
+is also available.
+
+Models that do not have named roles will have the data provided via
+the \e modelData role. The \e modelData role is also provided for
+Models that have only one role. In this case the \e modelData role
+contains the same data as the named role.
There are a number of QML elements that operate using data models:
@@ -189,4 +195,31 @@ ListView {
An Object Instance specifies a model with a single Object element. The
properties of the object are provided as roles.
+The example below creates a list with one item, showing the color of the
+\e myText text. Note the use of the \e model property to specify the model
+data rather than the \e color property of the Text element in the delegate.
+
+\code
+Rectangle {
+ Text {
+ id: myText
+ text: "Hello"
+ color: "#dd44ee"
+ }
+
+ Component {
+ id: myDelegate
+ Text {
+ text: model.color
+ }
+ }
+ ListView {
+ anchors.fill: parent
+ anchors.topMargin: 30
+ model: myText
+ delegate: myDelegate
+ }
+}
+\endcode
+
*/
diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc
index 1831cf8..18685ac 100644
--- a/doc/src/declarative/qtbinding.qdoc
+++ b/doc/src/declarative/qtbinding.qdoc
@@ -44,10 +44,16 @@
\target qtbinding
\title Using QML in C++ Applications
+\tableofcontents
+
The QML API is split into three main classes - QmlEngine, QmlComponent and QmlContext.
QmlEngine provides the environment in which QML is run, QmlComponent encapsulates
\l {QML Documents}, and QmlContext allows applications to expose data to QML component instances.
+QML also includes a convenience API, QmlView, for applications that simply want to embed QML
+components into a new QGraphicsView. QmlView covers up many of the details discussed below.
+While QmlView is mainly intended for rapid prototyping it can have uses in production applications.
+
\section1 Basic Usage
Every application requires at least one QmlEngine. A QmlEngine allows the configuration of
@@ -76,134 +82,182 @@ QML components are instantiated in a QmlContext. A context allows the applicati
to the QML component instance. A single QmlContext can be used to instantiate all the objects
used by an application, or several QmlContext can be created for more fine grained control over
the data exposed to each instance. If a context is not passed to the QmlComponent::create()
-method, the QmlEngine's \l {QmlEngine::rootContext()}{root context} is used.
+method, the QmlEngine's \l {QmlEngine::rootContext()}{root context} is used. Data exposed through
+the root context is available to all object instances.
-To expose data to a QML component instance, applications set \l {QmlContext::setContextProperty()}{context properties} which are then accessible by name from QML \l {Property Binding}s and
-\l {ECMAScript Blocks}.
+\section1 Simple Data
-\section1 Network Components
+To expose data to a QML component instance, applications set \l {QmlContext::setContextProperty()}
+{context properties} which are then accessible by name from QML \l {Property Binding}s and
+\l {ECMAScript Blocks}. The following example shows how to expose a background color to a QML
+file.
-If the URL passed to QmlComponent is a network resource, or if the QML document references a
-network resource, the QmlComponent has to fetch the network data before it is able to create
-objects. In this case, the QmlComponent will have a \l {QmlComponent::Loading}{Loading}
-\l {QmlComponent::status()}{status}. An application will have to wait until the component
-is \l {QmlComponent::Ready}{Ready} before calling \l {QmlComponent::create()}.
-
-The following example shows how to load a QML file from a network resource. After creating
-the QmlComponent, it tests whether the component is loading. If it is, it connects to the
-QmlComponent::statusChanged() signal and otherwise calls the \c {continueLoading()} method
-directly. This test is necessary, even for URLs that are known to be remote, just in case
-the component has been cached and is ready immediately.
+\table
+\row
+\o
+\code
+// main.cpp
+QmlContext *windowContext = new QmlContext(engine->rootContext());
+windowContext->setContextProperty("backgroundColor",
+ QColor(Qt::lightsteelblue));
+QmlComponent component(&engine, "main.qml");
+QObject *window = component.create(windowContext);
+\endcode
+\o
\code
-MyApplication::MyApplication()
-{
- // ...
- component = new QmlComponent(engine, QUrl("http://www.example.com/main.qml"));
- if (component->isLoading())
- QObject::connect(component, SIGNAL(statusChanged(QmlComponent::Status)),
- this, SLOT(continueLoading()));
- else
- continueLoading();
-}
+// main.qml
+import Qt 4.6
-void MyApplication::continueLoading()
-{
- if (component->isError()) {
- qWarning() << component->errors();
- } else {
- QObject *myObject = component->create();
+Rectangle {
+ color: backgroundColor
+
+ Text {
+ anchors.centerIn: parent
+ text: "Hello Light Steel Blue World!"
}
}
\endcode
+\endtable
-\section1 TODO
-\list
-\o QmlEngine and QmlComponent
-\o QmlContext and data
-\o QBindableMap
-\o QAbstractItemModel Data models
-\o QmlView
-\endlist
-
-*/
+Context properties work just like normal properties in QML bindings - if the \c backgroundColor
+context property in the previous example was changed to red, the component object instances would
+all be automatically updated.
-/*
-\section1 Overview
+QmlContexts form a tree - each QmlContext except for the root context has a parent. Child
+QmlContexts effectively inherit the context properties present in their parents. This gives
+applications more freedom in partitioning the data exposed to different QML object instances.
+If a QmlContext sets a context property that is also set in one of its parents, the new context
+property shadows that in the parent. In The following example, the \c background context property
+in \c {Context 1} shadows the \c background context property in the root context.
-The QML mechanisms of data binding can also be used to bind Qt C++ objects.
+\image qml-context-tree.png
-The data binding framework is based on Qt's property system (see the Qt documentation for more details on this system). If a binding is meant to be dynamic (where changes in one object are reflected in another object), \c NOTIFY must be specified for the property being tracked. If \c NOTIFY is not specified, any binding to that property will be an 'intialization' binding (the tracking object will be updated only once with the initial value of the tracked object).
+\section2 Structured Data
-Relevant items can also be bound to the contents of a Qt model.
-For example, ListView can make use of data from a QAbstractItemModel-derived model.
+Context properties can also be used to expose structured and writable data to QML objects. In
+addition to all the types already supported by QVariant, QObject derived types can be assigned to
+context properties. QObject context properties allow the data exposed to be more structured, and
+allow QML to set values.
-\section1 Passing Data Between C++ and QML
+The following example creates a \c CustomPalette object, and sets it as the \c palette context
+property.
-Data binding provides one method of data transfer between C++ and QML.
-
-For example, lets say you want to implement a slider in QML that changes the screen brightness of the device it is running on. You would start by declaring a brightness property on your QObject-derived class:
\code
-class MyScreen : public QObject
+class CustomPalette : public QObject
{
- Q_OBJECT
+Q_OBJECT
+Q_PROPERTY(QColor background READ background WRITE setBackground NOTIFY backgroundChanged)
+Q_PROPERTY(QColor text READ text WRITE setText NOTIFY text)
public:
- MyScreen(QObject *parent=0);
-
- Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged);
- int brightness() const;
- void setBrightness(int b);
- ...
-
-signals:
- void brightnessChanged();
+ CustomPalette() : m_background(Qt::white), m_text(Qt::black) {}
+
+ QColor background() const { return m_background; }
+ void setBackground(const QColor &c) {
+ if (c != m_background) {
+ m_background = c;
+ emit backgroundChanged();
+ }
+ }
+ QColor text() const { return m_text; }
+ void setText(const QColor &c) {
+ if (c != m_text) {
+ m_text = c;
+ emit textChanged();
+ }
+ }
private:
- int m_brightness;
+ QColor m_background;
+ QColor m_text;
};
-int brightness() const
+int main(int argc, char **argv)
{
- return m_brightness;
-}
+ // ...
-void setBrightness(int b)
-{
- if (b != m_brightness) {
- m_brightness = b;
- emit brightnessChanged();
+ QmlContext *windowContext = new QmlContext(engine->rootContext());
+ windowContext->setContextProperty("palette", new CustomPalette);
- //set device brightness
- ...
- }
+ QmlComponent component(&engine, "main.qml");
+ QObject *window = component.create(windowContext);
}
\endcode
-\note One important thing to keep in mind is that the changed signal should only be emitted when there is a real change ( \c b \c != \c m_brightness ), or you may get an infinite loop.
+The QML that follows references the palette object, and its properties, to set the appropriate
+background and text colors. When the window is clicked, the palette's text color is changed, and
+the window text will update accordingly.
-Next, make an instance of this class visible to the QML bind engine:
\code
-QmlView *view = new QmlView;
-view->setUrl("MyUI.qml");
-
-MyScreen *screen = new MyScreen;
-QmlContext *ctxt = view->rootContext();
-ctxt->setContextProperty("screen", screen);
+// main.qml
+import Qt 4.6
+
+Rectangle {
+ width: 240
+ height: 320
+ color: palette.background
+
+ Text {
+ anchors.centerIn: parent
+ color: palette.text
+ text: "Hello Colorful World!"
+ }
-view->execute();
+ MouseRegion {
+ anchors.fill: parent
+ onClicked: {
+ palette.text = "blue";
+ }
+ }
+}
\endcode
+\endtable
-\note Bindings must be made after setUrl() but before execute().
+To detect when a C++ property value - in this case the \c CustomPalette's \c text property -
+changes, the property must have a corresponding NOTIFY signal. The NOTIFY signal specifies a signal
+that is emitted whenever the property changes value. Implementers should take care to only emit the
+signal if the value \e changes to prevent loops from occuring. Accessing a property from a
+binding that does not have a NOTIFY signal will cause QML to issue a warning at runtime.
-Finally, in QML you can make the appropriate bindings, so in \c "MyUI.qml":
+\section2 Dynamic Structured Data
-\code
-Slider { value: screen.brightness }
-Binding { target: screen; property: "brightness"; value: slider.value }
-\endcode
+If an application is too dynamic to structure data as compile-time QObject types, dynamically
+structured data can be constructed at runtime using the QmlPropertyMap class.
-The \l QBindableMap class provides a convenient way to make data visible to the bind engine.
+\section1 Network Components
+
+If the URL passed to QmlComponent is a network resource, or if the QML document references a
+network resource, the QmlComponent has to fetch the network data before it is able to create
+objects. In this case, the QmlComponent will have a \l {QmlComponent::Loading}{Loading}
+\l {QmlComponent::status()}{status}. An application will have to wait until the component
+is \l {QmlComponent::Ready}{Ready} before calling \l {QmlComponent::create()}.
+
+The following example shows how to load a QML file from a network resource. After creating
+the QmlComponent, it tests whether the component is loading. If it is, it connects to the
+QmlComponent::statusChanged() signal and otherwise calls the \c {continueLoading()} method
+directly. This test is necessary, even for URLs that are known to be remote, just in case
+the component has been cached and is ready immediately.
-C++ \l {qmlmodels}{Data Models} may also be provided to QML.
+\code
+MyApplication::MyApplication()
+{
+ // ...
+ component = new QmlComponent(engine, QUrl("http://www.example.com/main.qml"));
+ if (component->isLoading())
+ QObject::connect(component, SIGNAL(statusChanged(QmlComponent::Status)),
+ this, SLOT(continueLoading()));
+ else
+ continueLoading();
+}
+void MyApplication::continueLoading()
+{
+ if (component->isError()) {
+ qWarning() << component->errors();
+ } else {
+ QObject *myObject = component->create();
+ }
+}
+\endcode
*/
+
diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc
index ebf7880..e01b02d 100644
--- a/doc/src/declarative/qtdeclarative.qdoc
+++ b/doc/src/declarative/qtdeclarative.qdoc
@@ -93,20 +93,15 @@ completely new applications. QML is fully \l {Extending QML}{extensible from C+
\o \l {Extending types from QML}
\endlist
-\section1 QML Reference:
+\section1 Reference:
\list
-\o \l {QML Format Reference}
\o \l {QML Elements}
-\endlist
-
-\section1 C++ Reference:
-\list
\o \l {Extending QML}
-\o \l {qtbinding}{QML/C++ Data Binding}
\endlist
\section1 Deprecated
-
+\list
\o \l {tutorials-declarative-contacts.html}{Tutorial: 'Introduction to QML'}
+\endlist
*/
diff --git a/doc/src/snippets/declarative/listview/highlight.qml b/doc/src/snippets/declarative/listview/highlight.qml
index 2234ee7..7970ede 100644
--- a/doc/src/snippets/declarative/listview/highlight.qml
+++ b/doc/src/snippets/declarative/listview/highlight.qml
@@ -20,6 +20,18 @@ Rectangle {
Text { text: '<b>Name:</b> ' + name }
Text { text: '<b>Number:</b> ' + number }
}
+ // Use the ListView.isCurrentItem attached property to
+ // indent the item if it is the current item.
+ states: [
+ State {
+ name: "Current"
+ when: wrapper.ListView.isCurrentItem
+ PropertyChanges { target: wrapper; x: 10 }
+ }
+ ]
+ transitions: [
+ Transition { NumberAnimation { properties: "x"; duration: 200 } }
+ ]
}
}
//! [0]