diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2020-02-21 15:12:56 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2020-02-24 13:49:14 +0100 |
commit | 86b3f39566ec597243718edb87498a653648457a (patch) | |
tree | dad3b546a868b205195de9c48b3cb111b40aea49 | |
parent | deb74c609e066b0efd73d1adbc6077e6ca7d8c45 (diff) |
Doc: Add section about QVariantList and QVariantMap as C++ properties
Change-Id: Ie18661274880f45d911baf05797a8b384d72f9f7
Fixes: QTBUG-82249
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
-rw-r--r-- | src/qml/doc/src/cppintegration/data.qdoc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/qml/doc/src/cppintegration/data.qdoc b/src/qml/doc/src/cppintegration/data.qdoc index 171b2b6a11..c91ce28f42 100644 --- a/src/qml/doc/src/cppintegration/data.qdoc +++ b/src/qml/doc/src/cppintegration/data.qdoc @@ -197,6 +197,25 @@ type or method parameter, the value can be created as a JavaScript array or object in QML, and is automatically converted to a QVariantList or QVariantMap when it is passed to C++. +Mind that QVariantList and QVariantMap properties of C++ types are stored as +values and cannot be changed in place by QML code. You can only replace the +whole map or list, but not manipulate its contents. The following code does +not work if the property \c l is a QVariantList: + +\code +MyListExposingItem { + l: [1, 2, 3] + Component.onCompleted: l[0] = 10 +} +\endcode + +The following code does work: +\code +MyListExposingItem { + l: [1, 2, 3] + Component.onCompleted: l = [10, 2, 3] +} +\endcode \section2 QDateTime to JavaScript Date |