このページでは

var以外のプロパティを優先する

この警告カテゴリのスペルは[prefer-non-var-properties] です。

var よりも具体的な型を優先する

何が起こったのでしょうか?

あなたはQMLのプロパティをintstring のような具体的な型ではなくvar という型で定義しました。

なぜそれが悪いのでしょうか?

これはコードの可読性に影響し、QMLツールは特定の型の最適化を適用することができません。

常に同じ型を保持するプロパティのプロパティ型としてvar を使うことは避けるべきです。誤検出を避けるため、qmllintは単純なバインディングを持つreadonlyプロパティにのみ警告を発します。それ以外の場合、複数の型を保持する必要があるためvarでなければならないプロパティと、常に同じ型を保持するプロパティを区別できない可能性があります。

import QtQuick

Item {
    readonly property var myP: 42
}

この警告を修正するには、var を特定の型に置き換えてください。

import QtQuick

Item {
    readonly property int myP: 42
}

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