diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2010-06-15 07:50:47 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2010-06-15 07:50:47 (GMT) |
commit | 45d9575a8c680206cdea0519b03996b6b8085294 (patch) | |
tree | d156b7d5c2dc0633c4468dce4cae4f0daf9e0035 /doc/src/declarative | |
parent | 01506a3b212d449d65df1131b49af0e174e45275 (diff) | |
parent | c1e6d97b9476c859abc3927046144b4006fcf735 (diff) | |
download | Qt-45d9575a8c680206cdea0519b03996b6b8085294.zip Qt-45d9575a8c680206cdea0519b03996b6b8085294.tar.gz Qt-45d9575a8c680206cdea0519b03996b6b8085294.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'doc/src/declarative')
20 files changed, 441 insertions, 421 deletions
diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc index 6e98949..c320898 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/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc index 43ae214..87dab81 100644 --- a/doc/src/declarative/basictypes.qdoc +++ b/doc/src/declarative/basictypes.qdoc @@ -40,363 +40,377 @@ ****************************************************************************/ /*! - \page qdeclarativebasictypes.html - \title QML Basic Types + \page qdeclarativebasictypes.html + \title QML Basic Types - QML has a set of primitive types, as listed below, that are used throughout - the \l {QML Elements}. + QML has a set of primitive types, as listed below, that are used throughout + the \l {QML Elements}. - Some of these types can also be used for defining - \c property values in QML. See \l{Extending types from QML} for the - list of types that can be used for \c property values. + Some of these types can also be used for defining + \c property values in QML. See \l{Extending types from QML} for the + list of types that can be used for \c property values. - \annotatedlist qmlbasictypes + \annotatedlist qmlbasictypes */ /*! - \qmlbasictype int - \ingroup qmlbasictypes + \qmlbasictype int + \ingroup qmlbasictypes - \brief An integer is a whole number, e.g. 0, 10, or -20. + \brief An integer is a whole number, e.g. 0, 10, or -20. - An integer is a whole number, e.g. 0, 10, or -20. The possible \c - int values range from around -2000000000 to around 2000000000, - although most elements will only accept a reduced range (which they - mention in their documentation). + An integer is a whole number, e.g. 0, 10, or -20. The possible \c + int values range from around -2000000000 to around 2000000000, + although most elements will only accept a reduced range (which they + mention in their documentation). - Example: - \qml - Item { width: 100; height: 200 } - \endqml + Example: + \qml + Item { width: 100; height: 200 } + \endqml - \sa {QML Basic Types} + \sa {QML Basic Types} */ /*! - \qmlbasictype bool - \ingroup qmlbasictypes + \qmlbasictype bool + \ingroup qmlbasictypes - \brief A boolean is a binary true/false value. + \brief A boolean is a binary true/false value. - A boolean is a binary true/false value. + A boolean is a binary true/false value. - Example: - \qml - Item { focus: true; clip: false } - \endqml + Example: + \qml + Item { focus: true; clip: false } + \endqml - \sa {QML Basic Types} + \sa {QML Basic Types} */ /*! - \qmlbasictype real - \ingroup qmlbasictypes + \qmlbasictype real + \ingroup qmlbasictypes - \brief A real number has a decimal point, e.g. 1.2 or -29.8. + \brief A real number has a decimal point, e.g. 1.2 or -29.8. - A real number has a decimal point, e.g. 1.2 or -29.8. + A real number has a decimal point, e.g. 1.2 or -29.8. - Example: - \qml - Item { width: 100.45; height: 150.82 } - \endqml + Example: + \qml + Item { width: 100.45; height: 150.82 } + \endqml - \note In QML all reals are stored in single precision, \l - {http://en.wikipedia.org/wiki/IEEE_754} {IEEE floating point} - format. + \note In QML all reals are stored in single precision, \l + {http://en.wikipedia.org/wiki/IEEE_754} {IEEE floating point} + format. - \sa {QML Basic Types} + \sa {QML Basic Types} */ /*! - \qmlbasictype string - \ingroup qmlbasictypes + \qmlbasictype string + \ingroup qmlbasictypes - \brief A string is a free form text in quotes, e.g. "Hello world!". + \brief A string is a free form text in quotes, e.g. "Hello world!". - A string is a free form text in quotes, e.g. "Hello world!". + A string is a free form text in quotes, e.g. "Hello world!". - Example: - \qml - Text { text: "Hello world!" } - \endqml + Example: + \qml + Text { text: "Hello world!" } + \endqml - \sa {QML Basic Types} + \sa {QML Basic Types} */ /*! - \qmlbasictype url - \ingroup qmlbasictypes + \qmlbasictype url + \ingroup qmlbasictypes - \brief A URL is a resource locator, like a file name. + \brief A URL is a resource locator, like a file name. - A URL is a resource locator, like a file name. It can be either - absolute, e.g. "http://qt.nokia.com", or relative, e.g. - "pics/logo.png". A relative URL is resolved relative to the URL of - the component where the URL is converted from a JavaScript string - expression to a url property value. + A URL is a resource locator, like a file name. It can be either + absolute, e.g. "http://qt.nokia.com", or relative, e.g. + "pics/logo.png". A relative URL is resolved relative to the URL of + the component where the URL is converted from a JavaScript string + expression to a url property value. - Example: - \qml - Image { source: "pics/logo.png" } - \endqml + Example: + \qml + Image { source: "pics/logo.png" } + \endqml - \raw HTML - \endraw + \raw HTML + \endraw - \sa {QML Basic Types} + \sa {QML Basic Types} */ /*! - \qmlbasictype color - \ingroup qmlbasictypes + \qmlbasictype color + \ingroup qmlbasictypes - \brief A color is a standard color name in quotes. + \brief A color is a standard color name in quotes. - A color is a standard color name in quotes. It is normally specified - as an \l {http://www.w3.org/TR/SVG/types.html#ColorKeywords} {SVG - color name}. These names include colors like "red", "green" and - "lightsteelblue". + A color is a standard color name in quotes. It is normally specified + as an \l {http://www.w3.org/TR/SVG/types.html#ColorKeywords} {SVG + color name}. These names include colors like "red", "green" and + "lightsteelblue". - If the color you want isn't part of this list, colors can also be - specified in hexidecimal triplets or quads that take the form \c - "#RRGGBB" and \c "#AARRGGBB" respectively. For example, the color - red corresponds to a triplet of \c "#FF0000" and a slightly - transparent blue to a quad of \c "#800000FF". + If the color you want isn't part of this list, colors can also be + specified in hexidecimal triplets or quads that take the form \c + "#RRGGBB" and \c "#AARRGGBB" respectively. For example, the color + red corresponds to a triplet of \c "#FF0000" and a slightly + transparent blue to a quad of \c "#800000FF". - Example: - \qml - Rectangle { color: "steelblue" } - Rectangle { color: "#FF0000" } - Rectangle { color: "#800000FF" } - \endqml + Example: + \qml + Rectangle { color: "steelblue" } + Rectangle { color: "#FF0000" } + Rectangle { color: "#800000FF" } + \endqml - Or with the \l{Qt::rgba()}{Qt.rgba()}, \l{Qt::hsla()}{Qt.hsla()}, \l{Qt::darker()}{Qt.darker()}, - \l{Qt::lighter()}{Qt.lighter()} or \l{Qt::tint()}{Qt.tint()} functions: + Or with the \l{Qt::rgba()}{Qt.rgba()}, \l{Qt::hsla()}{Qt.hsla()}, \l{Qt::darker()}{Qt.darker()}, + \l{Qt::lighter()}{Qt.lighter()} or \l{Qt::tint()}{Qt.tint()} functions: - \qml - Rectangle { color: Qt.rgba(255, 0, 0, 1) } - \endqml + \qml + Rectangle { color: Qt.rgba(255, 0, 0, 1) } + \endqml - \sa {QML Basic Types} + \sa {QML Basic Types} */ /*! - \qmlbasictype point - \ingroup qmlbasictypes + \qmlbasictype point + \ingroup qmlbasictypes - \brief A point is specified as "x,y". + \brief A point type has x and y attributes. - A point is specified as "x,y". + A \c point type has \c x and \c y attributes. - Example: - \qml - MyItem { position: "0,20" } - \endqml + To create a \c point value, specify it as a "x,y" string: - Or with the \l{Qt::point()}{Qt.point()} function: + \qml + CustomObject { myPointProperty: "0,20" } + \endqml - \qml - MyItem { position: Qt.point(0, 20) } - \endqml + Or use the \l{Qt::point()}{Qt.point()} function: - A point object has \c x and \c y attributes that contain the \c x and \c y values. + \qml + CustomObject { myPointProperty: Qt.point(0, 20) } + \endqml - \sa {QML Basic Types} + \sa {QML Basic Types} */ /*! - \qmlbasictype size - \ingroup qmlbasictypes + \qmlbasictype size + \ingroup qmlbasictypes + + \brief A size type has width and height attributes - \brief A size is specified as "width x height". + A \c size type has \c width and \c height attributes. - A size is specified as "width x height". + For example, to read the \l {Image::sourceSize} \c size property: - Example: - \qml - LayoutItem { preferredSize: "150x50" } - \endqml + \qml + Column { + Image { id: image; source: "logo.png" } + Text { text: image.sourceSize.width + "," + image.sourceSize.height } + } + \endqml - Or with the \l{Qt::size()}{Qt.size()} function: + To create a \c size value, specify it as a "width x height" string: - \qml - MyItem { position: Qt.size(150, 50) } - \endqml + \qml + LayoutItem { preferredSize: "150x50" } + \endqml - A size object has \c width and \c height attributes that contain the \c width and \c height values. + Or use the \l{Qt::size()}{Qt.size()} function: - \sa {QML Basic Types} + \qml + LayoutItem { preferredSize: Qt.size(150, 50) } + \endqml + + \sa {QML Basic Types} */ /*! - \qmlbasictype rect - \ingroup qmlbasictypes + \qmlbasictype rect + \ingroup qmlbasictypes + + \brief A rect type has x, y, width and height attributes. + + A \c rect type has \c x, \c y, \c width and \c height attributes. - \brief A rect is specified as "x, y, width x height". + For example, to read the \l {Item::childrenRect.x}{Item::childrenRect} \c rect property: + \qml + Rectangle { + width: childrenRect.width + height: childrenRect.height - A rect is specified as "x, y, width x height". + Rectangle { width: 100; height: 100 } + } + \endqml - Example: - \qml - MyItem { geometry: "50,50,100x100" } - \endqml + To create a \c rect value, specify it as a "x, y, width x height" string: - Or with the \l{Qt::rect()}{Qt.rect()} function: + \qml + CustomObject { myRectProperty: "50,50,100x100" } + \endqml - \qml - MyItem { position: Qt.rect(50, 50, 100, 100) } - \endqml + Or use the \l{Qt::rect()}{Qt.rect()} function: - A rect object has \c x, \c, y, \c width and \c height attributes that contain the - \c x, \c y, \c width and \c height values. + \qml + CustomObject { myRectProperty: Qt.rect(50, 50, 100, 100) } + \endqml - \sa {QML Basic Types} + \sa {QML Basic Types} */ /*! - \qmlbasictype date - \ingroup qmlbasictypes + \qmlbasictype date + \ingroup qmlbasictypes - \brief A date is specified as "YYYY-MM-DD". + \brief A date is specified as "YYYY-MM-DD". - A date is specified as "YYYY-MM-DD". + To create a \c date value, specify it as a "YYYY-MM-DD" string: - Example: - \qml - MyDatePicker { minDate: "2000-01-01"; maxDate: "2020-12-31" } - \endqml + Example: + \qml + MyDatePicker { minDate: "2000-01-01"; maxDate: "2020-12-31" } + \endqml - To read a date value returned from a C++ extension class, use - \l{Qt::formatDate()}{Qt.formatDate()} and \l{Qt::formatDateTime()}{Qt.formatDateTime()}. + To read a date value returned from a C++ extension class, use + \l{Qt::formatDate()}{Qt.formatDate()} and \l{Qt::formatDateTime()}{Qt.formatDateTime()}. - \sa {QML Basic Types} + \sa {QML Basic Types} */ /*! - \qmlbasictype time - \ingroup qmlbasictypes + \qmlbasictype time + \ingroup qmlbasictypes - \brief A time is specified as "hh:mm:ss". + \brief A time is specified as "hh:mm:ss". - A time is specified as "hh:mm:ss". + A time is specified as "hh:mm:ss". - Example: - \qml - MyTimePicker { time: "14:22:15" } - \endqml + Example: + \qml + MyTimePicker { time: "14:22:15" } + \endqml - To read a time value returned from a C++ extension class, use - \l{Qt::formatTime()}{Qt.formatTime()} and \l{Qt::formatDateTime()}{Qt.formatDateTime()}. + To read a time value returned from a C++ extension class, use + \l{Qt::formatTime()}{Qt.formatTime()} and \l{Qt::formatDateTime()}{Qt.formatDateTime()}. - \sa {QML Basic Types} + \sa {QML Basic Types} */ /*! - \qmlbasictype font - \ingroup qmlbasictypes + \qmlbasictype font + \ingroup qmlbasictypes - \brief A font type has the properties of a QFont. + \brief A font type has the properties of a QFont. - A font type has the properties of a QFont. The properties are: + A font type has the properties of a QFont. The properties are: - \list - \o \c string font.family - \o \c bool font.bold - \o \c bool font.italic - \o \c bool font.underline - \o \c real font.pointSize - \o \c int font.pixelSize - \endlist + \list + \o \c string font.family + \o \c bool font.bold + \o \c bool font.italic + \o \c bool font.underline + \o \c real font.pointSize + \o \c int font.pixelSize + \endlist - Example: - \qml - Text { font.family: "Helvetica"; font.pointSize: 13; font.bold: true } - \endqml + Example: + \qml + Text { font.family: "Helvetica"; font.pointSize: 13; font.bold: true } + \endqml - \sa {QML Basic Types} + \sa {QML Basic Types} */ /*! - \qmlbasictype action - \ingroup qmlbasictypes + \qmlbasictype action + \ingroup qmlbasictypes - \brief The action type has all the properties of QAction. + \brief The action type has all the properties of QAction. - The action type has all the properties of QAction. The properties - are: + The action type has all the properties of QAction. The properties + are: - \list - \o \c slot action.trigger - invoke the action - \o \c bool action.enabled - true if the action is enabled - \o \c string action.text - the text associated with the action - \endlist + \list + \o \c slot action.trigger - invoke the action + \o \c bool action.enabled - true if the action is enabled + \o \c string action.text - the text associated with the action + \endlist - Actions are used like this: + Actions are used like this: - \qml - MouseArea { onClicked: myaction.trigger() } - State { name: "enabled"; when: myaction.enabled == true } - Text { text: someaction.text } - \endqml + \qml + MouseArea { onClicked: myaction.trigger() } + State { name: "enabled"; when: myaction.enabled == true } + Text { text: someaction.text } + \endqml - \sa {QML Basic Types} + \sa {QML Basic Types} */ /*! - \qmlbasictype list - \ingroup qmlbasictypes - - \brief A list of objects. - - A list of objects. While not technically a basic type, QML also - supports lists of object types. When used from QML, the engine - automatically appends each value to the list. - - For example, the \l Item class contains a list property named - children that can be used like this: - - \qml - Item { - children: [ - Item { id: child1 }, - Rectangle { id: child2 }, - Text { id: child3 } - ] - } - \endqml - \c child1, \c child2 and \c child3 will all be added to the children list - in the order in which they appear. - - \sa {QML Basic Types} + \qmlbasictype list + \ingroup qmlbasictypes + + \brief A list of objects. + + A list of objects. While not technically a basic type, QML also + supports lists of object types. When used from QML, the engine + automatically appends each value to the list. + + For example, the \l Item class contains a list property named + children that can be used like this: + + \qml + Item { + children: [ + Item { id: child1 }, + Rectangle { id: child2 }, + Text { id: child3 } + ] + } + \endqml + \c child1, \c child2 and \c child3 will all be added to the children list + in the order in which they appear. + + \sa {QML Basic Types} */ /*! - \qmlbasictype vector3d - \ingroup qmlbasictypes + \qmlbasictype vector3d + \ingroup qmlbasictypes - \brief A vector3d is specified as "x,y,z". + \brief A vector3d type has x, y, and z attributes. - A vector3d is specified as "x,y,z". + A \c vector3d type has \c x, \c y, and \c z attributes. - \qml - Rotation { angle: 60; axis: "0,1,0" } - \endqml + To create a \c vector3d value, specify it as a "x,y,z" string: - or with the \c{Qt.vector3d()} function: + \qml + Rotation { angle: 60; axis: "0,1,0" } + \endqml - \qml - Rotation { angle: 60; axis: Qt.vector3d(0, 1, 0) } - \endqml + or with the \l{Qt::vector3d()}{Qt.vector3d()} function: - or as separate \c x, \c y, and \c z components: + \qml + Rotation { angle: 60; axis: Qt.vector3d(0, 1, 0) } + \endqml - \qml - Rotation { angle: 60; axis.x: 0; axis.y: 1; axis.z: 0 } - \endqml + or as separate \c x, \c y, and \c z components: - A vector3d object has \c x, \c, y, and \c z attributes that contain the - \c x, \c y, \c z values. + \qml + Rotation { angle: 60; axis.x: 0; axis.y: 1; axis.z: 0 } + \endqml - \sa {QML Basic Types} + \sa {QML Basic Types} */ diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc index 1199b26..7a49d0a 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 574a187..31fa948 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -59,8 +59,8 @@ The following table lists the QML elements provided by the \l {QtDeclarative}{Qt \o \l State \o \l PropertyChanges \o \l StateGroup +\o \l StateChangeScript \o \l ParentChange (Item-specific) -\o \l StateChangeScript (Item-specific) \o \l AnchorChanges (Item-specific) \endlist @@ -76,6 +76,7 @@ The following table lists the QML elements provided by the \l {QtDeclarative}{Qt \o \l ParentAnimation \o \l AnchorAnimation \o \l SmoothedAnimation +\o \l Vector3dAnimation \o \l PropertyAction \o \l ScriptAction \o \l Transition @@ -167,8 +168,8 @@ The following table lists the QML elements provided by the \l {QtDeclarative}{Qt \header \o \bold {Views} \o \bold {Positioners} -\o \bold {Media} \o \bold {Effects} +\o \row \o @@ -201,13 +202,6 @@ The following table lists the QML elements provided by the \l {QtDeclarative}{Qt \o \list -\o \l SoundEffect -\o \l Audio -\o \l Video -\endlist - -\o -\list \o \l Particles (experimental) \list \o \l ParticleMotionLinear diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index 8f39685..ad8c10c 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 @@ -117,6 +118,7 @@ For example, from your build directory, run: \o \l{declarative/modelviews/package}{Package} \o \l{declarative/modelviews/parallax}{Parallax} \o \l{declarative/modelviews/stringlistmodel}{String ListModel} +\o \l{declarative/modelviews/visualitemmodel}{VisualItemModel} \o \l{declarative/modelviews/webview}{WebView} \endlist diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index af5b437..03c0ec4 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -899,9 +899,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 Binary files differnew file mode 100644 index 0000000..4973e4e --- /dev/null +++ b/doc/src/declarative/pics/anchorchanges.png diff --git a/doc/src/declarative/pics/gridview-highlight.png b/doc/src/declarative/pics/gridview-highlight.png Binary files differnew file mode 100644 index 0000000..b54af37 --- /dev/null +++ b/doc/src/declarative/pics/gridview-highlight.png diff --git a/doc/src/declarative/pics/gridview-simple.png b/doc/src/declarative/pics/gridview-simple.png Binary files differnew file mode 100644 index 0000000..a102939 --- /dev/null +++ b/doc/src/declarative/pics/gridview-simple.png diff --git a/doc/src/declarative/pics/gridview.png b/doc/src/declarative/pics/gridview.png Binary files differdeleted file mode 100644 index 3726893..0000000 --- a/doc/src/declarative/pics/gridview.png +++ /dev/null diff --git a/doc/src/declarative/pics/listmodel-nested.png b/doc/src/declarative/pics/listmodel-nested.png Binary files differnew file mode 100644 index 0000000..ee7ffba --- /dev/null +++ b/doc/src/declarative/pics/listmodel-nested.png diff --git a/doc/src/declarative/pics/listmodel.png b/doc/src/declarative/pics/listmodel.png Binary files differnew file mode 100644 index 0000000..7ab1771 --- /dev/null +++ b/doc/src/declarative/pics/listmodel.png diff --git a/doc/src/declarative/pics/parentchange.png b/doc/src/declarative/pics/parentchange.png Binary files differnew file mode 100644 index 0000000..93206fb --- /dev/null +++ b/doc/src/declarative/pics/parentchange.png diff --git a/doc/src/declarative/pics/repeater-simple.png b/doc/src/declarative/pics/repeater-simple.png Binary files differnew file mode 100644 index 0000000..6da6295 --- /dev/null +++ b/doc/src/declarative/pics/repeater-simple.png diff --git a/doc/src/declarative/pics/translate.png b/doc/src/declarative/pics/translate.png Binary files differnew file mode 100644 index 0000000..baf58b0 --- /dev/null +++ b/doc/src/declarative/pics/translate.png diff --git a/doc/src/declarative/pics/visualitemmodel.png b/doc/src/declarative/pics/visualitemmodel.png Binary files differnew file mode 100644 index 0000000..5e6d132 --- /dev/null +++ b/doc/src/declarative/pics/visualitemmodel.png diff --git a/doc/src/declarative/qdeclarativedocument.qdoc b/doc/src/declarative/qdeclarativedocument.qdoc index bc099ce..8336512 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 0000000..b535e4b --- /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 fd0c677..43b5c31 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 cef5e63..66b4b2b 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. |