aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc/src
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2023-10-13 14:20:02 +0200
committerSami Shalayel <sami.shalayel@qt.io>2023-12-29 18:11:07 +0200
commitaea585d9ffcb8a5a8664831de01cbfac018262ad (patch)
treefc21fa8e29bb32488bd4bf74ec8aeca452f908bd /src/qml/doc/src
parent50f461d4df1c628c81c63f506bd1ae15a5bfec14 (diff)
doc: add read-only-property warning in qmllint warnings
Add description of the warning and an example on how to fix it. Task-number: QTBUG-111137 Change-Id: I7ec0f77ac21d8fb6146a38f43977de0ef604af7c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/doc/src')
-rw-r--r--src/qml/doc/src/qmllint/read-only-property.qdoc28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/qml/doc/src/qmllint/read-only-property.qdoc b/src/qml/doc/src/qmllint/read-only-property.qdoc
index 8a6a266b6e..7bc6b5fcc2 100644
--- a/src/qml/doc/src/qmllint/read-only-property.qdoc
+++ b/src/qml/doc/src/qmllint/read-only-property.qdoc
@@ -5,22 +5,34 @@
\page qmllint-warnings-and-errors-read-only-property.html
\ingroup qmllint-warnings-and-errors
-\title read-only-property
-\brief BRIEF
+\title Readonly Property
+\brief A readonly property was written.
-\section1 read-only-property
+\section1 Cannot Assign To Read-Only Property
\section2 What happened?
-TODO
+A \l{Read-Only Properties}{read-only property} was written.
\section2 Why is this bad?
-TODO
+The QML engine will throw a Type Error when it sees the write to a read-only property.
\section2 Example
\qml
+import QtQuick
+
+Item {
+ id: root
+ readonly property int someNumber: 10
+
+ Component.onCompleted: {
+ someNumber = 20 // not ok: TypeError: Cannot assign to read-only property
+ }
+}
\endqml
-You can fix this warning by TODO
-\qml
-\endqml
+You can fix this warning by removing the write to the read-only property, by writing to another
+non-read-only property, or by removing the readonly modifier if the property should no longer be
+considered constant.
+
+\sa{Read-Only Properties}
*/