summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-05-31 06:59:48 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-05-31 07:00:42 (GMT)
commit4759e47a2444d481156ad1a789e5affbc92e1b58 (patch)
treed4c418c0da23c7ad4ab595475cd71a89075a2249
parente5cc765d2fa1ff68f1592ad475d6b8f4e5a6f667 (diff)
downloadQt-4759e47a2444d481156ad1a789e5affbc92e1b58.zip
Qt-4759e47a2444d481156ad1a789e5affbc92e1b58.tar.gz
Qt-4759e47a2444d481156ad1a789e5affbc92e1b58.tar.bz2
Various doc fixes and improvements
-rw-r--r--doc/src/declarative/basictypes.qdoc67
-rw-r--r--doc/src/declarative/globalobject.qdoc2
-rw-r--r--doc/src/declarative/pics/repeater-modeldata.pngbin0 -> 2600 bytes
-rw-r--r--doc/src/declarative/qml-intro.qdoc26
-rw-r--r--doc/src/snippets/declarative/repeater-modeldata.qml52
-rw-r--r--examples/declarative/sqllocalstorage/hello.qml2
-rw-r--r--examples/declarative/tutorials/extending/chapter1-basics/app.qml1
-rw-r--r--examples/declarative/tutorials/extending/chapter2-methods/app.qml1
-rw-r--r--examples/declarative/tutorials/extending/chapter3-bindings/app.qml1
-rw-r--r--examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml1
-rw-r--r--src/declarative/graphicsitems/qdeclarativerepeater.cpp14
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp34
12 files changed, 159 insertions, 42 deletions
diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc
index 8db1c35..43ae214 100644
--- a/doc/src/declarative/basictypes.qdoc
+++ b/doc/src/declarative/basictypes.qdoc
@@ -46,9 +46,9 @@
QML has a set of primitive types, as listed below, that are used throughout
the \l {QML Elements}.
- The simpler types in this list can also be used for defining a new
- \c property in a component. See \l{Extending types from QML} for the
- list of types that can be used for custom properties.
+ 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
*/
@@ -171,6 +171,13 @@
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:
+
+ \qml
+ Rectangle { color: Qt.rgba(255, 0, 0, 1) }
+ \endqml
+
\sa {QML Basic Types}
*/
@@ -184,9 +191,17 @@
Example:
\qml
- Widget { pos: "0,20" }
+ MyItem { position: "0,20" }
\endqml
+ Or with the \l{Qt::point()}{Qt.point()} function:
+
+ \qml
+ MyItem { position: Qt.point(0, 20) }
+ \endqml
+
+ A point object has \c x and \c y attributes that contain the \c x and \c y values.
+
\sa {QML Basic Types}
*/
@@ -200,9 +215,17 @@
Example:
\qml
- Widget { size: "150x50" }
+ LayoutItem { preferredSize: "150x50" }
+ \endqml
+
+ Or with the \l{Qt::size()}{Qt.size()} function:
+
+ \qml
+ MyItem { position: Qt.size(150, 50) }
\endqml
+ A size object has \c width and \c height attributes that contain the \c width and \c height values.
+
\sa {QML Basic Types}
*/
@@ -216,9 +239,18 @@
Example:
\qml
- Widget { geometry: "50,50,100x100" }
+ MyItem { geometry: "50,50,100x100" }
\endqml
+ Or with the \l{Qt::rect()}{Qt.rect()} function:
+
+ \qml
+ MyItem { position: Qt.rect(50, 50, 100, 100) }
+ \endqml
+
+ 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.
+
\sa {QML Basic Types}
*/
@@ -232,9 +264,12 @@
Example:
\qml
- DatePicker { minDate: "2000-01-01"; maxDate: "2020-12-31" }
+ 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()}.
+
\sa {QML Basic Types}
*/
@@ -248,9 +283,12 @@
Example:
\qml
- TimePicker { time: "14:22:15" }
+ 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()}.
+
\sa {QML Basic Types}
*/
@@ -297,9 +335,9 @@
Actions are used like this:
\qml
- MouseArea { onClicked: MyItem.myaction.trigger() }
- State { name: "enabled"; when: MyItem.myaction.enabled == true }
- Text { text: MyItem.someaction.text }
+ MouseArea { onClicked: myaction.trigger() }
+ State { name: "enabled"; when: myaction.enabled == true }
+ Text { text: someaction.text }
\endqml
\sa {QML Basic Types}
@@ -327,7 +365,7 @@
]
}
\endqml
- \c Child1, \c Child2 and \c Child3 will all be added to the children list
+ \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}
@@ -345,7 +383,7 @@
Rotation { angle: 60; axis: "0,1,0" }
\endqml
- or with the \c{Qt.vector3d()} helper function:
+ or with the \c{Qt.vector3d()} function:
\qml
Rotation { angle: 60; axis: Qt.vector3d(0, 1, 0) }
@@ -357,5 +395,8 @@
Rotation { angle: 60; axis.x: 0; axis.y: 1; axis.z: 0 }
\endqml
+ A vector3d object has \c x, \c, y, and \c z attributes that contain the
+ \c x, \c y, \c z values.
+
\sa {QML Basic Types}
*/
diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc
index 7d4f9b9..3121e95 100644
--- a/doc/src/declarative/globalobject.qdoc
+++ b/doc/src/declarative/globalobject.qdoc
@@ -49,7 +49,7 @@ Contains all the properties of the JavaScript global object, plus:
\section1 Qt Object
-The \l{qml-qt.html}{Qt object} provides useful enums and functions from Qt, for use in all QML
+The \l{Qt}{Qt object} provides useful enums and functions from Qt, for use in all QML
files.
\section1 XMLHttpRequest
diff --git a/doc/src/declarative/pics/repeater-modeldata.png b/doc/src/declarative/pics/repeater-modeldata.png
new file mode 100644
index 0000000..817f35b
--- /dev/null
+++ b/doc/src/declarative/pics/repeater-modeldata.png
Binary files differ
diff --git a/doc/src/declarative/qml-intro.qdoc b/doc/src/declarative/qml-intro.qdoc
index 64a4949..848e094 100644
--- a/doc/src/declarative/qml-intro.qdoc
+++ b/doc/src/declarative/qml-intro.qdoc
@@ -864,49 +864,49 @@ paused, and reaching the end of the media. They allow the developer to connect,
some QML that will handle this event.
-\section1 Analyzing An Example: Dial
+\section1 Analyzing An Example: Dial Control
-In the Qt \e {examples/declarative/toys} folder you will find a folder
-\e {dial} which contains the \e dial example.
+In the Qt \e {examples/declarative/ui-components} folder you will find a folder
+\e {dialcontrol} which contains the \e dialcontrol example.
\image qml-dial.png "QML Dial example with Slider"
In essence this small application has a sliding bar that you can slide using
a mouse, and a graphical dial that responds to the position of the slider.
-The code for the example is in two parts: Dial.qml and dial-example.qml.
+The code for the example is in two parts: Dial.qml and dialcontrol.qml.
-\e {Dial.qml} can be found in the \e content sub-directory. It defines a Dial
+\e {Dial.qml} can be found in the \e content sub-directory. It defines a \c Dial
component similar to an odometer. Eventually, the example will hook up a slider
component so that moving the slider will change the position of a needle on the
dial.
-The code for the Dial, identified by the name of the file, contains four images
+The code for the \c Dial, identified by the name of the file, contains four images
in overlapping order: the background (numbers and divisions), the shadow of the
needle, the needle itself, and finally the 'glass' overlay (containing
transparent layers).
-The needle_shadow.png image has a Rotation assigned to the \e transform
+The \c needle_shadow.png image has a \l Rotation assigned to the \e transform
attribute of the \l Image. The rotation is set to match the angle of the needle
image angle value \e {needleRotation.angle}. Both the needle and the
needle_shadow have the same default \e x and \e y values but the rotation origin
for the needle is slightly different so that a shadow will be evident as the
needle moves.
-\snippet ../../examples/declarative/toys/dial/content/Dial.qml needle_shadow
+\snippet ../../examples/declarative/ui-components/dialcontrol/content/Dial.qml needle_shadow
And the needle
-\snippet ../../examples/declarative/toys/dial/content/Dial.qml needle
+\snippet ../../examples/declarative/ui-components/dialcontrol/content/Dial.qml needle
The final image is the overlay which simply has a position defined.
-\snippet ../../examples/declarative/toys/dial/content/Dial.qml overlay
+\snippet ../../examples/declarative/ui-components/dialcontrol/content/Dial.qml overlay
-\e {dial-example.qml} in the \e {examples/declarative/toys/dial} directory is the
+\e {dialcontrol.qml} in the \e {examples/declarative/ui-components/dialcontrol} directory is the
main file of the example. It defines the visual environment that the Dial
will fit into. Because the \e Dial component and the images live in the \e
-content sub-directory we will have to import this into \e dial-example. So the
+content sub-directory we will have to import this into \e dialcontrol.qml. So the
start of the file looks like
\code
@@ -919,7 +919,7 @@ a gray color. Inside this rectangle is our component \e Dial and a \l Rectangle.
Inside the rectangle called 'container' is another rectangle with the
interesting name 'slider'.
-\snippet ../../examples/declarative/toys/dial/dial-example.qml 0
+\snippet ../../examples/declarative/ui-components/dialcontrol/dialcontrol.qml 0
The Dial component, named 'dial, is \e anchored to the center of the main
rectangle. The \c value attribute of 'dial' is set to a value based on the
diff --git a/doc/src/snippets/declarative/repeater-modeldata.qml b/doc/src/snippets/declarative/repeater-modeldata.qml
new file mode 100644
index 0000000..3b4cc6d
--- /dev/null
+++ b/doc/src/snippets/declarative/repeater-modeldata.qml
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** 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 QtDeclarative module 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$
+**
+****************************************************************************/
+
+import Qt 4.7
+
+//! [0]
+Column {
+ Repeater {
+ model: ["apples", "oranges", "pears"]
+ Text { text: "Data: " + modelData }
+ }
+}
+//! [0]
+
diff --git a/examples/declarative/sqllocalstorage/hello.qml b/examples/declarative/sqllocalstorage/hello.qml
index 0913d42..421a74c 100644
--- a/examples/declarative/sqllocalstorage/hello.qml
+++ b/examples/declarative/sqllocalstorage/hello.qml
@@ -68,4 +68,4 @@ Text {
Component.onCompleted: findGreetings()
}
-
+//![0]
diff --git a/examples/declarative/tutorials/extending/chapter1-basics/app.qml b/examples/declarative/tutorials/extending/chapter1-basics/app.qml
index 7de32f2..9af155c 100644
--- a/examples/declarative/tutorials/extending/chapter1-basics/app.qml
+++ b/examples/declarative/tutorials/extending/chapter1-basics/app.qml
@@ -55,3 +55,4 @@ Rectangle {
text: aMusician.name + " plays the " + aMusician.instrument
}
}
+//![0]
diff --git a/examples/declarative/tutorials/extending/chapter2-methods/app.qml b/examples/declarative/tutorials/extending/chapter2-methods/app.qml
index 495413f..02d33c2 100644
--- a/examples/declarative/tutorials/extending/chapter2-methods/app.qml
+++ b/examples/declarative/tutorials/extending/chapter2-methods/app.qml
@@ -57,3 +57,4 @@ Rectangle {
onClicked: aMusician.perform()
}
}
+//![0]
diff --git a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml
index 46408cb..8bf6ecf 100644
--- a/examples/declarative/tutorials/extending/chapter3-bindings/app.qml
+++ b/examples/declarative/tutorials/extending/chapter3-bindings/app.qml
@@ -69,3 +69,4 @@ Rectangle {
}
}
}
+//![0]
diff --git a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml
index 09662d6..d76f801 100644
--- a/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml
+++ b/examples/declarative/tutorials/extending/chapter4-customPropertyTypes/app.qml
@@ -51,3 +51,4 @@ Item {
Component.onCompleted: console.log("Reddy plays the " + reddy.instrument.type)
}
+//![0]
diff --git a/src/declarative/graphicsitems/qdeclarativerepeater.cpp b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
index 04076f8..691cfa2 100644
--- a/src/declarative/graphicsitems/qdeclarativerepeater.cpp
+++ b/src/declarative/graphicsitems/qdeclarativerepeater.cpp
@@ -80,14 +80,20 @@ QDeclarativeRepeaterPrivate::~QDeclarativeRepeaterPrivate()
The index is always exposed as an accessible \c index property.
In the case of an object or string list, the data element (of type string
or object) is available as the \c modelData property. In the case of a Qt model,
- all roles are available as named properties just like in the view classes. The
- following example shows how to use the index property inside the instantiated
- items.
+ all roles are available as named properties just like in the view classes.
- \snippet doc/src/snippets/declarative/repeater-index.qml 0
+ The following example shows how to use the \c index property inside the instantiated
+ items:
+ \snippet doc/src/snippets/declarative/repeater-index.qml 0
\image repeater-index.png
+ The repeater could also use the \c modelData property to reference the data for a
+ particular index:
+
+ \snippet doc/src/snippets/declarative/repeater-modeldata.qml 0
+ \image repeater-modeldata.png
+
Items instantiated by the Repeater are inserted, in order, as
children of the Repeater's parent. The insertion starts immediately after
the repeater's position in its parent stacking list. This is to allow
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 8679e76..d8c842b 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -155,14 +155,26 @@ void QDeclarativeEnginePrivate::defineModule()
\qmlclass Qt QDeclarativeEnginePrivate
\brief The QML global Qt object provides useful enums and functions from Qt.
-The Qt object provides useful enums and functions from Qt, for use in all QML files.
+The \c Qt object provides useful enums and functions from Qt, for use in all QML files.
+
+The \c Qt object is not a QML element; it cannot be instantiated. It is a global object
+with enums and functions. To use it, call the members of the global \c Qt object directly.
+For example:
+
+\qml
+import Qt 4.7
+
+Text {
+ color: Qt.rgba(255, 0, 0, 1)
+ text: Qt.md5("hello, world")
+}
+\endqml
-You do not create instances of this type, but instead use the members of the global "Qt" object.
\section1 Enums
The Qt object contains all enums in the Qt namespace. For example, you can
-access the AlignLeft member of the Qt::AlignmentFlag enum with \c Qt.AlignLeft.
+access the \c AlignLeft member of the \c Qt::AlignmentFlag enum with \c Qt.AlignLeft.
For a full list of enums, see the \l{Qt Namespace} documentation.
@@ -172,7 +184,7 @@ data types. This is primarily useful when setting the properties of an item
when the property has one of the following types:
\list
-\o \c color - use \l{Qt::rgba()}{Qt.rgba()}, \l{Qt::darker()}{Qt.darker()}, \l{Qt::lighter()}{Qt.lighter()} or \l{Qt::tint()}{Qt.tint()}
+\o \c color - use \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()}
\o \c rect - use \l{Qt::rect()}{Qt.rect()}
\o \c point - use \l{Qt::point()}{Qt.point()}
\o \c size - use \l{Qt::size()}{Qt.size()}
@@ -200,8 +212,8 @@ items from files or strings. See \l{Dynamic Object Management} for an overview
of their use.
\list
- \o \l{Qt::createComponent}{object Qt.createComponent(url)}
- \o \l{Qt::createQmlObject}{object Qt.createQmlObject(string qml, object parent, string filepath)}
+ \o \l{Qt::createComponent()}{object Qt.createComponent(url)}
+ \o \l{Qt::createQmlObject()}{object Qt.createQmlObject(string qml, object parent, string filepath)}
\endlist
*/
@@ -1034,7 +1046,7 @@ QString QDeclarativeEnginePrivate::urlToLocalFileOrQrc(const QUrl& url)
/*!
\qmlmethod object Qt::createComponent(url)
-Returns a \l Component object created from the QML file at the specified \a url,
+Returns a \l Component object created using the QML file at the specified \a url,
or \c null if there was an error in creating the component.
Call \l {Component::createObject()}{Component.createObject()} on the returned
@@ -1360,7 +1372,7 @@ QScriptValue QDeclarativeEnginePrivate::formatDateTime(QScriptContext*ctxt, QScr
/*!
\qmlmethod color Qt::rgba(real red, real green, real blue, real alpha)
-Returns a Color with the specified \c red, \c green, \c blue and \c alpha components.
+Returns a color with the specified \c red, \c green, \c blue and \c alpha components.
All components should be in the range 0-1 inclusive.
*/
QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine *engine)
@@ -1388,7 +1400,7 @@ QScriptValue QDeclarativeEnginePrivate::rgba(QScriptContext *ctxt, QScriptEngine
/*!
\qmlmethod color Qt::hsla(real hue, real saturation, real lightness, real alpha)
-Returns a Color with the specified \c hue, \c saturation, \c lightness and \c alpha components.
+Returns a color with the specified \c hue, \c saturation, \c lightness and \c alpha components.
All components should be in the range 0-1 inclusive.
*/
QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine *engine)
@@ -1416,7 +1428,9 @@ QScriptValue QDeclarativeEnginePrivate::hsla(QScriptContext *ctxt, QScriptEngine
/*!
\qmlmethod rect Qt::rect(int x, int y, int width, int height)
-Returns a Rect with the top-left corner at \c x, \c y and the specified \c width and \c height.
+Returns a \c rect with the top-left corner at \c x, \c y and the specified \c width and \c height.
+
+The returned object has \c x, \c y, \c width and \c height attributes with the given values.
*/
QScriptValue QDeclarativeEnginePrivate::rect(QScriptContext *ctxt, QScriptEngine *engine)
{