このページでは

プロパティの欠落

この警告カテゴリのスペルは[missing-property] です。

存在しないデフォルト・プロパティに代入できない

何が起こりましたか?

存在しないデフォルト・プロパティにオブジェクトを割り当てました。

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

QMLエンジンは実行時にこのオブジェクトを割り当てることができません。

import QtQuick

Item {
    component MyType: QtObject { property Item myItem; }

    MyType {
        Item {}
    }
}

この警告を修正するには、バインドしたいプロパティを指定するか、もしあなたが型の作成者であれば、プロパティをデフォルトとしてマークしてください:

import QtQuick

Item {
    component MyType: QtObject { property Item myItem; }

    MyType {
        myItem: Item {}
    }

    component AlternativeMyType: QtObject { default property Item myItem; }

    AlternativeMyType {
        Item {} // bound to myItem via default property
    }
}

プロパティが存在しません

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

存在しないプロパティに式を割り当てました。

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

QMLエンジンは実行時にこの式を代入することができません。

import QtQuick

Item {
    property int myInt
    myItn: 42
}

この警告を修正するには、バインディングを削除するか、タイプミスを修正してください:

import QtQuick

Item {
    property int myInt
    myInt: 42
}

型にメンバが見つかりません

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

QMLツールで見つけられないフィールドメンバ式内のメンバにアクセスしました。フィールド・メンバー式とは、someId.someProperty という形式の式です。

例えば、タイプミスをした場合などです。あるいは、実行時には存在するが(常に存在する特定のサブタイプに存在するため)、静的に宣言された型には存在しないかもしれません。

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

QMLツールはこのメンバを見つけることができません。つまり、go-to-definitionやオートコンプリートのような機能が動作しません。実行時に、そのメンバが本当に存在しない場合、エラーが発生したり、正しくない結果が得られるかもしれません。実行時にメンバが常に存在する場合はエラーは発生しませんが、その場合でも最適化の失敗によるパフォーマンス・コストが発生する可能性があります。

プロパティが実際には存在しません

import QtQuick

Item {
    id: self
    property int myInt
    property int myInt2: 1 + self.myItn
}

この警告を修正するには、バインディングを削除するか、タイプミスを修正してください:

import QtQuick

Item {
    id: self
    property int myInt
    property int myInt2: 1 + self.myInt
}

プロパティは存在するが、型が十分正確でない

import QtQuick
import QtQuick.Controls.Basic

Item {
  component Message : Item {
    required property string sender
    required property string text
  }
  ListView {
    id: messageView
    delegate: Message {}
  }

  Button {
    text: "Reply to %1".arg(messageView.currentItem.sender) // not ok
  }
}

この警告を修正するには、読み取ったオブジェクトをより具体的な型にキャストします:

import QtQuick
import QtQuick.Controls.Basic

Item {
  component Message : Item {
    required property string sender
    required property string text
  }
  ListView {
    id: messageView
    delegate: Message {}
  }

  Button {
    text: "Reply to %1".arg((messageView.currentItem as Message).sender) // now ok
  }
}

この例では、messageView'のcurrentItem プロパティの宣言された型はItem であり、sender プロパティはありません。senderMessage でのみ定義されています。しかし、currentItem は常にMessage を含むことが分かっているので、型アサーションを使用してcurrentItemMessage にキャストできます。

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