diff options
author | Ville Voutilainen <ville.voutilainen@qt.io> | 2017-04-18 16:55:20 +0300 |
---|---|---|
committer | Ville Voutilainen <ville.voutilainen@qt.io> | 2017-04-21 17:15:07 +0000 |
commit | c50113aaf4515c172a1dd2eb30532de088307d78 (patch) | |
tree | c9919336796b5297ea36b29a4b4bb7ffc9779c09 /src/qml/doc/src/cppintegration | |
parent | ac29d0811ee1d712aefd2468374354de948bebfd (diff) |
Add support for std::vector and QVector matching the support for QList
Task-number: QTBUG-60133
Change-Id: I5497dc3c4a1c3922e7147d7a20593c75a0d9d0e9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/doc/src/cppintegration')
-rw-r--r-- | src/qml/doc/src/cppintegration/data.qdoc | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/qml/doc/src/cppintegration/data.qdoc b/src/qml/doc/src/cppintegration/data.qdoc index 4523ee39d8..9cc7291583 100644 --- a/src/qml/doc/src/cppintegration/data.qdoc +++ b/src/qml/doc/src/cppintegration/data.qdoc @@ -273,10 +273,17 @@ In particular, QML currently supports: \li \c {QList<qreal>} \li \c {QList<bool>} \li \c {QList<QString>} and \c{QStringList} + \li \c {QVector<QString>} + \li \c {std::vector<QString>} \li \c {QList<QUrl>} + \li \c {QVector<QUrl>} + \li \c {std::vector<QUrl>} \li \c {QVector<int>} \li \c {QVector<qreal>} \li \c {QVector<bool>} + \li \c {std::vector<int>} + \li \c {std::vector<qreal>} + \li \c {std::vector<bool>} \endlist These sequence types are implemented directly in terms of the underlying C++ @@ -296,6 +303,10 @@ If the sequence is returned from a Q_INVOKABLE function, access and mutation is much cheaper, as no QObject property read or write occurs; instead, the C++ sequence data is accessed and modified directly. +In both the Q_PROPERTY and return from Q_INVOKABLE cases, the elements +of a std::vector are copied. This copying may be an expensive operation, +so std::vector should be used judiciously. + 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. @@ -318,10 +329,17 @@ The default-constructed values for each sequence type are as follows: \row \li QList<qreal> \li real value 0.0 \row \li QList<bool> \li boolean value \c {false} \row \li QList<QString> and QStringList \li empty QString +\row \li QVector<QString> \li empty QString +\row \li std::vector<QString> \li empty QString \row \li QList<QUrl> \li empty QUrl +\row \li QVector<QUrl> \li empty QUrl +\row \li std::vector<QUrl> \li empty QUrl \row \li QVector<int> \li integer value 0 \row \li QVector<qreal> \li real value 0.0 \row \li QVector<bool> \li boolean value \c {false} +\row \li std::vector<int> \li integer value 0 +\row \li std::vector<qreal> \li real value 0.0 +\row \li std::vector<bool> \li boolean value \c {false} \endtable If you wish to remove elements from a sequence rather than simply replace |