1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
5\page qmllint-warnings-and-errors-read-only-property.html
6\ingroup qmllint-warnings-and-errors
8\title Readonly Property
9\brief A readonly property was written.
11\section1 Cannot Assign To Read-Only Property
13\section2 What happened?
14A \l{Read-Only Properties}{read-only property} was written.
16\section2 Why is this bad?
17The QML engine will throw a Type Error when it sees the write to a read-only property.
25 readonly property int someNumber: 10
27 Component.onCompleted: {
28 someNumber = 20 // not ok: TypeError: Cannot assign to read-only property
32You can fix this warning by removing the write to the read-only property, by writing to another
33non-read-only property, or by removing the readonly modifier if the property should no longer be
36\sa{Read-Only Properties}