summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-12-22 05:35:27 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-12-22 05:35:27 (GMT)
commit51ca2e67fe20c3de5740279837916b8bcc4f7060 (patch)
tree777f9727e09655fa2a9a06979500113ec9d23177
parent27c18a5cd8dbe2d22c8717044922ad5437e6fff4 (diff)
parent2d4d125313d79fb80f513952bed675b7126392fd (diff)
downloadQt-51ca2e67fe20c3de5740279837916b8bcc4f7060.zip
Qt-51ca2e67fe20c3de5740279837916b8bcc4f7060.tar.gz
Qt-51ca2e67fe20c3de5740279837916b8bcc4f7060.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Document the 'variant' basic type Add double type to QML Basic Types docs Remove redundant docs
-rw-r--r--doc/src/declarative/basictypes.qdoc95
-rw-r--r--doc/src/declarative/extending.qdoc24
-rw-r--r--doc/src/declarative/qdeclarativereference.qdoc81
3 files changed, 107 insertions, 93 deletions
diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc
index 034b7d1..e9d3a44 100644
--- a/doc/src/declarative/basictypes.qdoc
+++ b/doc/src/declarative/basictypes.qdoc
@@ -95,6 +95,26 @@
*/
/*!
+ \qmlbasictype double
+ \ingroup qmlbasictypes
+
+ \brief A double number has a decimal point and is stored in double precision.
+
+ A double number has a decimal point and is stored in double precision, \l
+ {http://en.wikipedia.org/wiki/IEEE_754} {IEEE floating point}
+ format.
+
+ Example:
+ \qml
+ Item {
+ property double number: 32155.2355
+ }
+ \endqml
+
+ \sa {QML Basic Types}
+*/
+
+/*!
\qmlbasictype string
\ingroup qmlbasictypes
@@ -412,7 +432,8 @@
list only modify a \e copy of the list and not the actual list. (These current limitations
are due to restrictions on \l {Property Binding} where lists are involved.)
- To create a modifiable list, create an array object from within a \c .js JavaScript file,
+ You can, however, modify a copy of the list and then reassign the property to the modified
+ value. Other options are to create an array object from within a \c .js JavaScript file,
or implement a custom list element in C++. Here is a QML element that modifies the list in a
JavaScript file:
@@ -452,6 +473,78 @@
\sa {QML Basic Types}
*/
+
+/*!
+ \qmlbasictype variant
+ \ingroup qmlbasictypes
+
+ \brief A variant type is a generic property type.
+
+ A variant is a generic property type. A variant type property can hold any of the
+ \l {QML Basic Types}{basic type} values:
+
+ \qml
+ Item {
+ property variant aNumber : 100
+ property variant aString : "Hello world!"
+ property variant aList : [ 1, 2, "buckle my shoe" ]
+ }
+ \endqml
+
+ The \c variant type can also hold a \e copy of a JavaScript object. For example, the
+ \c animal property below defines a JavaScript object defined with JSON notation. The
+ object's properties and values can be examined using the standard JavaScript syntax,
+ as shown in the \c Component.onCompleted handler.
+
+ \qml
+ Item {
+ property variant animal : { 'type': 'bird', 'species': 'galah', 'age': 7 }
+
+ Component.onCompleted: {
+ for (var attribute in animal)
+ console.log(attribute, "=", animal[attribute])
+ }
+ }
+ \endqml
+
+ It must be noted that the \c animal property holds a \e copy of the defined object, and
+ not the object itself. (This is true even if the property refers to an object defined in
+ some JavaScript file; the property will hold a copy of the object, and not the actual
+ object.) The property essentially holds a copy of the contents within the object. This
+ has several implications:
+
+ \list
+ \o Changes to any of the property's values (for example, the \c animal.type value
+ above) only modify the \e copy of the object, not the object itself. You can, however,
+ modify a copy of the object and then reassign the property to the modified value.
+ \o Because the property only holds a copy of the object, \l{Property Binding}{bindings} to
+ any of the property's individual values are not updated until the whole property is
+ reassigned to a new value. For example:
+
+ \qml
+ Item {
+ property variant animal : { 'type': 'bird', 'species': 'galah', 'age': 7 }
+
+ Text { text: "Animal species: " + animal.species }
+
+ Component.onCompleted: {
+ animal.species = 'kookaburra' // this has no effect on the displayed text
+
+ var newObj = animal
+ newObj.species = 'kookaburra'
+ animal = newObj // this will update the displayed text
+ }
+ }
+ \endqml
+ \o Since the object values are copied, it does not hold any reference to the original
+ object, and extra data such as the object's JavaScript prototype chain is lost in the
+ process.
+ \endlist
+
+ \sa {QML Basic Types}
+*/
+
+
/*!
\qmlbasictype vector3d
\ingroup qmlbasictypes
diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc
index 748ec6c..ff519f6 100644
--- a/doc/src/declarative/extending.qdoc
+++ b/doc/src/declarative/extending.qdoc
@@ -753,15 +753,15 @@ with their default values and the corresponding C++ type:
\table
\header \o QML Type Name \o Default value \o C++ Type Name
-\row \o int \o 0 \o int
-\row \o bool \o \c false \o bool
-\row \o double \o 0.0 \o double
-\row \o real \o 0.0 \o double
-\row \o string \o "" (empty string) \o QString
-\row \o url \o "" (empty url) \o QUrl
-\row \o color \o #000000 (black) \o QColor
-\row \o date \o \c undefined \o QDateTime
-\row \o variant \o \c undefined \o QVariant
+\row \o \l int \o 0 \o int
+\row \o \l bool \o \c false \o bool
+\row \o \l double \o 0.0 \o double
+\row \o \l real \o 0.0 \o double
+\row \o \l string \o "" (empty string) \o QString
+\row \o \l url \o "" (empty url) \o QUrl
+\row \o \l color \o #000000 (black) \o QColor
+\row \o \l date \o \c undefined \o QDateTime
+\row \o \l variant \o \c undefined \o QVariant
\endtable
QML object types can also be used as property types. This includes
@@ -776,6 +776,10 @@ property MyCustomType customProperty
Such object-type properties default to an \c undefined value.
+It is also possible to store a copy of a JavaScript object using the \c variant
+property type. This creates some restrictions on how the property should be used;
+see the \l {variant}{variant type documentation} for details.
+
\l{list}{List properties} are created with the \c list<Type> syntax, and default to an empty
list:
@@ -786,8 +790,6 @@ property list<Item> listOfItems
Note that list properties cannot be modified like ordinary JavaScript
arrays. See the \l {list}{list type documentation} for details.
-For details about accessing and manipulating QML properties from C++, see \l {Using QML with C++}.
-
\section2 Property change signals
diff --git a/doc/src/declarative/qdeclarativereference.qdoc b/doc/src/declarative/qdeclarativereference.qdoc
deleted file mode 100644
index c2c5e91..0000000
--- a/doc/src/declarative/qdeclarativereference.qdoc
+++ /dev/null
@@ -1,81 +0,0 @@
-/****************************************************************************
-**
-** 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:FDL$
-** 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 Free Documentation License
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of this
-** file.
-**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-/*!
- \page qdeclarativereference.html
- \title QML Reference
-
- \target qtdeclarativemainpage
-
- QML is a language for building the animation rich,
- highly fluid user interfaces that are becoming common in portable consumer
- electronics devices such as mobile phones, media players, set-top boxes and
- netbooks. It is also appropriate for highly custom desktop
- user interfaces, or special elements in more traditional desktop user interfaces.
-
- Building fluid applications is done declaratively, rather than procedurally.
- That is, you specify \e what the UI should look like and how it should behave
- rather than specifying step-by-step \e how to build it. Specifying a UI declaratively
- does not just include the layout of the interface items, but also the way each
- individual item looks and behaves and the overall flow of the application.
-
- The QML elements provide a sophisticated set of graphical and behavioral building
- blocks. These different elements are combined together in \l {QML Documents}{QML documents} to build components
- ranging in complexity from simple buttons and sliders, to complete
- internet-enabled applications like a \l {http://www.flickr.com}{Flickr} photo browser.
-
- Getting Started:
- \list
- \o \l {Introduction to the QML language}
- \o \l {QML Tutorial}{Tutorial: 'Hello World'}
- \o \l {QML Advanced Tutorial}{Advanced Tutorial: 'Same Game'}
- \o \l {QML Examples and Demos}
- \endlist
-
- \section1 Core QML Features:
- \list
- \o \l {QML Documents}
- \o \l {Property Binding}
- \o \l {Integrating JavaScript}
- \o \l {QML Scope}
- \o \l {Network Transparency}
- \o \l {qmlmodels}{Data Models}
- \o \l {anchor-layout}{Anchor-based Layout}
- \o \l {qmlstates}{States}
- \o \l {qdeclarativeanimation.html}{Animation}
- \o \l {qdeclarativemodules.html}{Modules}
- \o \l {qmlfocus}{Keyboard Focus}
- \o \l {Extending types from QML}
- \endlist
-
- QML Reference:
- \list
- \o \l {elements}{QML Elements}
- \o \l {QML Global Object}
- \o \l {QML Internationalization}
- \endlist
-*/