- Qt 6.8
- Qt QML
- QML Lint Warning and Errors
- Readonly Property
- Qt 6.8.0 Reference Documentation

# Readonly Property

## Cannot Assign To Read-Only Property

### What happened?

A read-only property was written.

### Why is this bad?

The QML engine will throw a Type Error when it sees the write to a read-only property.

### Example

     import QtQuick

     Item {
         id: root
         readonly property int someNumber: 10

         Component.onCompleted: {
             someNumber = 20  // not ok: TypeError: Cannot assign to read-only property
         }
     }

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.

See also Read-Only Properties.