Proprietà di sola lettura
Questa categoria di avviso viene indicata da qmllint come " [read-only-property] ".
Impossibile assegnare un valore a una proprietà di sola lettura
Cosa è successo?
È stata modificata una proprietà di sola lettura.
Perché è un problema?
Il motore QML genererà un errore di tipo (Type Error) quando rileva una scrittura su una proprietà di sola lettura.
Esempio
import QtQuick
Item {
id: root
readonly property int someNumber: 10
Component.onCompleted: {
someNumber = 20 // not ok: TypeError: Cannot assign to read-only property
}
}Per risolvere questo avviso, rimuovere la scrittura sulla proprietà di sola lettura, eseguire la scrittura su un’altra proprietà non di sola lettura oppure rimuovere il modificatore `readonly` se si è l’autore della definizione della proprietà.
Vedi anche Proprietà di sola lettura.
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.