aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorChris Adams <christopher.adams@nokia.com>2011-11-21 10:02:35 +1000
committerQt by Nokia <qt-info@nokia.com>2011-11-29 04:34:11 +0100
commitc648598a8ba8bf72b5d556211df877578d5f5b64 (patch)
tree47cfe3fe9ac48fdd609ac51e5351de925da7dec2 /doc
parent5587885a71b962eb9443c1f83e3e477490bd691d (diff)
Add indexed deleter to sequence wrapper, implement length setter
Previously, elements could not be deleted from sequences directly without reassignment. This commit adds an indexed deleter which allows elements to be deleted by specifying an index. A deleted element will be replaced with a default-constructed element in the sequence (slight departure from ECMA262r3 which specifies that it should be replaced with Undefined). This commit also implements the length property setter according to the requirements on Array [[Put]] by ECMA262r3 which allows removal of elements from a sequence (required for proper behaviour of Array.prototype methods such as splice() and pop()). Task-number: QTBUG-22808 Change-Id: I62511b3edc2ec35f92d2a2bd719278e129c98547 Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/src/declarative/extending.qdoc23
1 files changed, 22 insertions, 1 deletions
diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc
index c1c7547ec2..385469c29f 100644
--- a/doc/src/declarative/extending.qdoc
+++ b/doc/src/declarative/extending.qdoc
@@ -252,7 +252,7 @@ In particular, QML currently supports:
\o \c {QList<int>}
\o \c {QList<qreal>}
\o \c {QList<bool>}
- \o \c {QList<QString>}
+ \o \c {QList<QString>} and \c{QStringList}
\o \c {QList<QUrl>}
\endlist
@@ -274,6 +274,27 @@ modified directly.
Other sequence types are not supported transparently, and instead an instance of any other
sequence type will be passed between QML and C++ as an opaque QVariantList.
+\bold {Important Note:} There are some minor differences between the semantics of such
+sequence Array types and default JavaScript Array types which result from the use of a
+C++ storage type in the implementation. In particular, deleting an element from an Array
+will result in a default-constructed value replacing that element, rather than an
+Undefined value. Similarly, setting the length property of the Array to a value larger
+than its current value will result in the Array being padded out to the specified length
+with default-constructed elements rather than Undefined elements.
+
+The default-constructed values for each sequence type are as follows:
+\table
+\row \o QList<int> \o integer value 0
+\row \o QList<qreal> \o real value 0.0
+\row \o QList<bool> \o boolean value \c {false}
+\row \o QList<QString> and QStringList \o empty QString
+\row \o QList<QUrl> \o empty QUrl
+\endtable
+
+If you wish to remove elements from a sequence rather than simply replace them with default
+constructed values, do not use the indexed delete operator ("delete sequence[i]") but instead
+use the \c {splice} function ("sequence.splice(startIndex, deleteCount)").
+
\section1 Inheritance and Coercion
\snippet examples/declarative/cppextensions/referenceexamples/coercion/example.qml 0