summaryrefslogtreecommitdiffstats
path: root/doc/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/declarative')
-rw-r--r--doc/src/declarative/animation.qdoc149
-rw-r--r--doc/src/declarative/declarativeui.qdoc1
-rw-r--r--doc/src/declarative/elements.qdoc2
-rw-r--r--doc/src/declarative/examples.qdoc1
-rw-r--r--doc/src/declarative/extending.qdoc10
-rw-r--r--doc/src/declarative/pics/anchorchanges.pngbin0 -> 566 bytes
-rw-r--r--doc/src/declarative/pics/listmodel-nested.pngbin0 -> 7493 bytes
-rw-r--r--doc/src/declarative/pics/listmodel.pngbin0 -> 3407 bytes
-rw-r--r--doc/src/declarative/pics/parentchange.pngbin0 -> 509 bytes
-rw-r--r--doc/src/declarative/qdeclarativedocument.qdoc18
-rw-r--r--doc/src/declarative/qdeclarativeperformance.qdoc120
-rw-r--r--doc/src/declarative/qdeclarativestates.qdoc52
-rw-r--r--doc/src/declarative/qmlruntime.qdoc22
13 files changed, 192 insertions, 183 deletions
diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc
index 6e98949d9b..c320898330 100644
--- a/doc/src/declarative/animation.qdoc
+++ b/doc/src/declarative/animation.qdoc
@@ -46,14 +46,14 @@
Animation in QML is done by animating properties of objects. Properties of type
real, int, color, rect, point, size, and vector3d can all be animated.
-QML supports three main forms of animation - basic property animation,
+QML supports three main forms of animation: basic property animation,
transitions, and property behaviors.
\tableofcontents
\section1 Basic Property Animation
-The simplest form of animation is directly using \l PropertyAnimation, which can animate all of the property
+The simplest form of animation is a \l PropertyAnimation, which can animate all of the property
types listed above. If the property you are animating is a number or color, you can alternatively use
NumberAnimation or ColorAnimation. These elements don't add any additional functionality,
but will help enforce type correctness and are slightly more efficient.
@@ -62,61 +62,23 @@ A property animation can be specified as a value source using the \e Animation \
for repeating animations.
The following example creates a bouncing effect:
-\qml
-Rectangle {
- id: rect
- width: 120; height: 200;
- Image {
- id: img
- source: "qt-logo.png"
- x: 60-img.width/2
- y: 0
- SequentialAnimation on y {
- loops: Animation.Infinite
- NumberAnimation { to: 200-img.height; easing.type: Easing.OutBounce; duration: 2000 }
- PauseAnimation { duration: 1000 }
- NumberAnimation { to: 0; easing.type: Easing.OutQuad; duration: 1000 }
- }
- }
-}
-\endqml
+\snippet doc/src/snippets/declarative/animation.qml property-anim-1
\image propanim.gif
When you assign an animation as a value source, you do not need to specify \c property
-or \c target; they are automatically selected for you. You do, however, need to specify \c to.
+or \c target values; they are automatically selected for you. You do, however, need to specify a \c to value.
An animation specified as a value source will be \c running by default.
-\qml
-Rectangle {
- id: rect
- width: 200; height: 200;
- Rectangle {
- color: "red"
- width: 50; height: 50
- NumberAnimation on x { to: 50 }
- }
-}
-\endqml
+For example, here is a rectangle that uses a \l NumberAnimation value source to animate the movement
+from its current position to an \c x value of 50. The animation starts immediately, and only the \c to
+property is required:
+
+\snippet doc/src/snippets/declarative/animation.qml property-anim-2
A property animation can also be specified as a resource that is manipulated from script.
-\qml
-PropertyAnimation {
- id: animation
- target: image
- property: "scale"
- from: 1; to: .5
-}
-Image {
- id: image
- source: "image.png"
- MouseArea {
- anchors.fill: parent
- onPressed: animation.start()
- }
-}
-\endqml
+\snippet doc/src/snippets/declarative/animation.qml property-anim-3
As can be seen, when an animation is used like this (as opposed to as a value source) you will need
to explicitly set the \c target and \c property to animate.
@@ -131,50 +93,20 @@ can only be triggered by a state change.
For example, a transition could describe how an item moves from its initial position to its new position:
-\code
-transitions: [
- Transition {
- NumberAnimation {
- properties: "x,y"
- easing.type: Easing.OutBounce
- duration: 200
- }
- }
-]
-\endcode
+\snippet doc/src/snippets/declarative/animation.qml transitions-1
As can be seen, transitions make use of the same basic animation classes introduced above.
In the above example we have specified that we want to animate the \c x and \c y properties, but have not
-specified the objects to animate or the \c to values. By default these values are supplied by the framework --
+specified the objects to animate or the \c to values. By default these values are supplied by the framework;
the animation will animate any \c targets whose \c x and \c y have changed, and the \c to values will be those
defined in the end state. You can always supply explicit values to override these implicit values when needed.
-\code
-Transition {
- from: "*"
- to: "MyState"
- reversible: true
- SequentialAnimation {
- NumberAnimation {
- duration: 1000
- easing.type: Easing.OutBounce
- // animate myItem's x and y if they have changed in the state
- target: myItem
- properties: "x,y"
- }
- NumberAnimation {
- duration: 1000
- // animate myItem2's y to 200, regardless of what happens in the state
- target: myItem2
- property: "y"
- to: 200
- }
- }
-}
-\endcode
+\snippet doc/src/snippets/declarative/animation.qml transitions-2
QML transitions have selectors to determine which state changes a transition should apply to.
The following transition will only be triggered when we enter into the \c "details" state.
+(The "*" value is a wildcard value that specifies the transition should be applied when changing
+from \e any state to the "details" state.)
\code
Transition {
@@ -188,30 +120,7 @@ Transitions can happen in parallel, in sequence, or in any combination of the tw
animations in a transition will happen in parallel. The following example shows a rather complex transition
making use of both sequential and parallel animations:
-\code
-Transition {
- from: "*"
- to: "MyState"
- reversible: true
- SequentialAnimation {
- ColorAnimation { duration: 1000 }
- PauseAnimation { duration: 1000 }
- ParallelAnimation {
- NumberAnimation {
- duration: 1000
- easing.type: Easing.OutBounce
- targets: box1
- properties: "x,y"
- }
- NumberAnimation {
- duration: 1000
- targets: box2
- properties: "x,y"
- }
- }
- }
-}
-\endcode
+\snippet doc/src/snippets/declarative/animation.qml transitions-3
\section1 Property Behaviors
@@ -219,24 +128,15 @@ A \l{Behavior}{property behavior} specifies a default animation to run whenever
of what caused the change. The \c enabled property can be used to force a \l Behavior
to only apply under certain circumstances.
-In the following snippet, we specify that we want the x position of redRect to be animated
-whenever it changes. The animation will last 300 milliseconds and use an InOutQuad easing curve.
+In the following snippet, we specify that we want the \c x position of \c redRect to be animated
+whenever it changes. The animation will last 300 milliseconds and use an \l{PropertyAnimation::easing.type}{Easing.InOutQuad} easing curve.
-\qml
-Rectangle {
- id: redRect
- color: "red"
- width: 100; height: 100
- Behavior on x { NumberAnimation { duration: 300; easing.type: Easing.InOutQuad } }
-}
-\endqml
+\snippet doc/src/snippets/declarative/animation.qml behavior
Like using an animation as a value source, when used in a Behavior and animation does not need to specify
a \c target or \c property.
-To trigger this behavior, we could:
-\list
-\o Enter a state that changes x
+To trigger this behavior, we could enter a state that changes \c x:
\qml
State {
@@ -249,7 +149,7 @@ State {
}
\endqml
-\o Update x from a script
+Or, update \c x from a script:
\qml
MouseArea {
@@ -257,11 +157,10 @@ MouseArea {
onClicked: redRect.x = 24;
}
\endqml
-\endlist
-If x were bound to another property, triggering the binding would also trigger the behavior.
+If \c x were bound to another property, triggering the binding would also trigger the behavior.
-If a state change has a transition animation matching a property with a Behavior, the transition animation
-will override the Behavior for that state change.
+If a state change has a transition animation matching a property with a \l Behavior, the transition animation
+will override the \l Behavior for that state change.
*/
diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc
index 1199b264ac..7a49d0a9cb 100644
--- a/doc/src/declarative/declarativeui.qdoc
+++ b/doc/src/declarative/declarativeui.qdoc
@@ -118,6 +118,7 @@ application or to build completely new applications. QML is fully \l
\o \l {QML Security}
\o \l {QtDeclarative Module}
\o \l {Debugging QML}
+\o \l {QML Performance}
\o \l {QML Coding Conventions}
\endlist
*/
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc
index aa48bcbc83..31fa948b43 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -211,6 +211,4 @@ The following table lists the QML elements provided by the \l {QtDeclarative}{Qt
\endlist
\endtable
-\o
-
*/
diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc
index 8f396857bc..cc67664435 100644
--- a/doc/src/declarative/examples.qdoc
+++ b/doc/src/declarative/examples.qdoc
@@ -79,6 +79,7 @@ For example, from your build directory, run:
\section2 Image Elements
\list
\o \l{declarative/imageelements/borderimage}{BorderImage}
+\o \l{declarative/imageelements/image}{Image}
\endlist
\section2 Positioners
diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc
index 574b0b2971..173fb6dc41 100644
--- a/doc/src/declarative/extending.qdoc
+++ b/doc/src/declarative/extending.qdoc
@@ -896,9 +896,13 @@ in other projects without the use of C++. Components can also help to reduce
duplication inside one project by limiting the need for large numbers of
copy-and-pasted blocks.
-Any snippet of QML code can become a component, just by placing it in the file
-"<Name>.qml" where <Name> is the new element name, and begins with an uppercase
-letter. These QML files automatically become available as new QML element types
+Any snippet of QML code can become a component, just by placing it in the file "<Name>.qml"
+where <Name> is the new element name, and begins with an uppercase letter. Note that
+the case of all characters in the <Name> are significant on some filesystems, notably
+UNIX filesystems. It is recommended that the case of the filename matches the case of
+the component name in QML exactly, regardless of the platform the QML will be deployed to.
+
+These QML files automatically become available as new QML element types
to other QML components and applications in the same directory.
For example, here we show how a component named "Box" is defined and used
diff --git a/doc/src/declarative/pics/anchorchanges.png b/doc/src/declarative/pics/anchorchanges.png
new file mode 100644
index 0000000000..4973e4e9aa
--- /dev/null
+++ b/doc/src/declarative/pics/anchorchanges.png
Binary files differ
diff --git a/doc/src/declarative/pics/listmodel-nested.png b/doc/src/declarative/pics/listmodel-nested.png
new file mode 100644
index 0000000000..ee7ffba67a
--- /dev/null
+++ b/doc/src/declarative/pics/listmodel-nested.png
Binary files differ
diff --git a/doc/src/declarative/pics/listmodel.png b/doc/src/declarative/pics/listmodel.png
new file mode 100644
index 0000000000..7ab1771f15
--- /dev/null
+++ b/doc/src/declarative/pics/listmodel.png
Binary files differ
diff --git a/doc/src/declarative/pics/parentchange.png b/doc/src/declarative/pics/parentchange.png
new file mode 100644
index 0000000000..93206fbbb2
--- /dev/null
+++ b/doc/src/declarative/pics/parentchange.png
Binary files differ
diff --git a/doc/src/declarative/qdeclarativedocument.qdoc b/doc/src/declarative/qdeclarativedocument.qdoc
index bc099ced80..833651243f 100644
--- a/doc/src/declarative/qdeclarativedocument.qdoc
+++ b/doc/src/declarative/qdeclarativedocument.qdoc
@@ -96,9 +96,6 @@ Once created, instances are not dependent on the component that created them, so
operate on independent data. Here is an example of a simple "Button" component that is
instantiated four times, each with a different value for its \c text property.
-\table
-\row
-\o
\raw HTML
<table><tr><td>
\endraw
@@ -125,10 +122,19 @@ BorderImage {
\raw HTML
</td> </tr> </table>
\endraw
-\endtable
-In addition to the top-level component that all QML documents define, documents may also
-include additional \e inline components. Inline components are declared using the
+Any snippet of QML code can become a component, just by placing it in the file "<Name>.qml"
+where <Name> is the new element name, and begins with an uppercase letter. Note that
+the case of all characters in the <Name> are significant on some filesystems, notably
+UNIX filesystems. It is recommended that the case of the filename matches the case of
+the component name in QML exactly, regardless of the platform the QML will be deployed to.
+
+These QML files automatically become available as new QML element types
+to other QML components and applications in the same directory.
+
+In addition to the top-level component that all QML documents define, and any reusable
+components placed in separate files, documents may also
+include \e inline components. Inline components are declared using the
\l Component element, as can be seen in the first example above. Inline components share
all the characteristics of regular top-level components and use the same \c import list as their
containing QML document. Components are one of the most basic building blocks in QML, and are
diff --git a/doc/src/declarative/qdeclarativeperformance.qdoc b/doc/src/declarative/qdeclarativeperformance.qdoc
new file mode 100644
index 0000000000..b535e4bb06
--- /dev/null
+++ b/doc/src/declarative/qdeclarativeperformance.qdoc
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying
+** this package.
+**
+** 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.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+\page qdeclarativeperformance.html
+\title QML Performance
+
+\section1 Opaque Items
+
+Items hidden behind an opaque item incur a cost. If an item will be enitrely
+obscured by an opaque item, set its opacity to 0. One common example of
+this is when a "details" page is shown over the main application view.
+
+\section1 Clipping
+
+\e clip is set to false by default. Enable clipping only when necessary.
+
+\section1 Anchors vs. Binding
+
+It is more efficient to use anchors rather than bindings to position items
+relative to each other. Consider this use of bindings to position rect2
+relative to rect1:
+
+\code
+Rectangle {
+ id: rect1
+ x: 20
+ width: 200; height: 200
+}
+Rectange {
+ id: rect2
+ x: rect1.x
+ y: rect1.y + rect1.height
+ width: rect1.width - 20
+ height: 200
+}
+\endcode
+
+This is achieved more efficiently using anchors:
+
+\code
+Rectangle {
+ id: rect1
+ x: 20
+ width: 200; height: 200
+}
+Rectange {
+ id: rect2
+ height: 200
+ anchors.left: rect1.left
+ anchors.top: rect1.bottom
+ anchors.right: rect1.right
+ anchors.rightMargin: 20
+}
+\endcode
+
+\section1 Images
+
+Images consume a great deal of memory and may also be costly to load. In order
+to deal with large images efficiently it is recommended that the Image::sourceSize
+property be set to a size no greater than that necessary to render it. Beware that
+changing the sourceSize will cause the image to be reloaded.
+
+Images on the local filesystem are usually loaded synchronously. This is usually
+the desired behavior for user interface elements, however for large images that
+do not necessarily need to be visible immediately, set the Image::asynchronous
+property to true. This will load the image in a low priority thread.
+
+\section1 View Delegates
+
+Delegates must be created quickly as the view is flicked. There are two important
+aspects to maintaining a smooth view:
+
+\list
+\o Small delegates - keep the amount of QML to a minimum. Have just enough
+QML in the delegate to display the necessary information. Any additional functionality
+that is only needed when the delegate is clicked, for example, should be created by
+a Loader as needed.
+\o Fast data access - ensure the data model is as fast as possible.
+\endlist
+
+*/
diff --git a/doc/src/declarative/qdeclarativestates.qdoc b/doc/src/declarative/qdeclarativestates.qdoc
index fd0c677728..43b5c31746 100644
--- a/doc/src/declarative/qdeclarativestates.qdoc
+++ b/doc/src/declarative/qdeclarativestates.qdoc
@@ -70,58 +70,30 @@ In QML:
\o A state can affect the properties of other objects, not just the object owning the state (and not just that object's children).
\endlist
+To define a state for an item, add a \l State element to the \l{Item::states}{states} property. To
+change the current state of an \l Item, set the \l{Item::state}{state} property to the name
+of the required state.
+
Here is an example of using states. In the default state \c myRect is positioned at 0,0. In the 'moved' state it is positioned at 50,50. Clicking within the mouse area changes the state from the default state to the 'moved' state, thus moving the rectangle.
-\qml
-Item {
- id: myItem
-
- Rectangle {
- id: myRect
- width: 100
- height: 100
- color: "red"
- }
-
- states: [
- State {
- name: "moved"
- PropertyChanges {
- target: myRect
- x: 50
- y: 50
- }
- }
- ]
-
- MouseArea {
- anchors.fill: parent
- onClicked: myItem.state = 'moved'
- }
-}
-\endqml
+\snippet doc/src/snippets/declarative/states.qml 0
+\snippet doc/src/snippets/declarative/states.qml 1
State changes can be animated using \l{state-transitions}{Transitions}.
-For example, adding this code to the above \c {Item {}} element animates the transition to the "moved" state:
+For example, adding this code to the above \c Item element animates the transition to the "moved" state:
-\qml
- transitions: [
- Transition {
- NumberAnimation { properties: "x,y"; duration: 500 }
- }
- ]
-\endqml
+\snippet doc/src/snippets/declarative/states.qml transitions
See \l{state-transitions}{Transitions} for more information.
Other things you can do in a state change:
\list
-\o override signal handlers with PropertyChanges
-\o change an item's visual parent with ParentChange
-\o change an item's anchors with AnchorChanges
-\o run some script with StateChangeScript
+\o Override signal handlers with PropertyChanges
+\o Change an item's visual parent with ParentChange
+\o Change an item's anchors with AnchorChanges
+\o Run some script with StateChangeScript
\endlist
*/
diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc
index cef5e6320a..66b4b2bf76 100644
--- a/doc/src/declarative/qmlruntime.qdoc
+++ b/doc/src/declarative/qmlruntime.qdoc
@@ -152,7 +152,7 @@
\section2 Runtime Object
- All applications using the launcher will have access to the 'runtime'
+ All applications using the launcher will have access to the \c runtime
property on the root context. This property contains several pieces of
information about the runtime environment of the application.
@@ -160,11 +160,19 @@
A special piece of dummy data which is integrated into the launcher is
a simple orientation property. The orientation can be set via the
- settings menu in the application, or by pressing Ctrl+T to toggle it.
+ settings menu in the application, or by pressing Ctrl+T to rotate it.
- To use this from within your QML file, access runtime.orientation,
- which can be either Orientation.Landscape or Orientation.Portrait and which can be bound to in your
- application. An example is below:
+ To use this from within your QML file, access \c runtime.orientation,
+ which can be one of the following values:
+
+ \list
+ \o \c Orientation.Portrait
+ \o \c Orientation.Landscape
+ \o \c Orientation.PortraitInverted (Portrait orientation, upside-down)
+ \o \c Orientation.LandscapeInverted (Landscape orientation, upside-down)
+ \endlist
+
+ These values can be bound to in your application. For example:
\code
Item {
@@ -172,13 +180,13 @@
}
\endcode
- This allows your application to respond to the orientation of the screen changing. The launcher
+ This allows your application to respond to changes in the screen's orientation. The launcher
will automatically update this on some platforms (currently the N900 only) to match the physical
screen's orientation. On other plaforms orientation changes will only happen when explictly asked for.
\section3 Window Active
- The runtime.isActiveWindow property tells whether the main window of the launcher is currently active
+ The \c runtime.isActiveWindow property tells whether the main window of the launcher is currently active
or not. This is especially useful for embedded devices when you want to pause parts of your application,
including animations, when your application loses focus or goes to the background.