読み取り専用プロパティ

この警告カテゴリーはqmllintによって[read-only-property]

読み取り専用プロパティに代入できません

何が起こりましたか?

読み取り専用プロパティが書き込まれました。

これはなぜ悪いのでしょうか?

QMLエンジンは読み取り専用プロパティへの書き込みを検出するとタイプエラーをスローします。

import QtQuick

Item {
    id: root
    readonly property int someNumber: 10

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

この警告を修正するには、読み取り専用プロパティへの書き込みを削除するか、読み取り専用でない別のプロパティに書き込むか、プロパティ定義の作成者であればreadonly修飾子を削除してください。

読み取り専用プロパティ」も参照してください

© 2025 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.