互換性のないタイプ

この警告カテゴリーはqmllintによって[incompatible-type]

互換性のない型のデフォルトプロパティに代入できません。

何が起こりましたか?

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

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

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

import QtQuick

Item {
    component MyType: QtObject {
        default property list<Item> myDefaultProperty
    }

    MyType {
        QtObject {} // note: QtObject does not inherit from Item
    }
}

この警告を修正するには、互換性のある型をプロパティにバインドするか、デフォルト・プロパティの作成者であれば、定義の型を変更してください:

import QtQuick

Item {
    component MyType: QtObject {
        default property list<Item> myDefaultProperty
    }

    MyType {
        Item {}
    }

    component AlternativeMyType: QtObject {
        default property list<QtObject> myDefaultProperty
    }

    AlternativeMyType {
        QtObject {} // is ok for AlternativeMyType
    }
}

プロパティのバインド時の型が間違っています

何が起こったのですか?

無効なプロパティ修飾子の型を使用しました。

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

QMLエンジンは実行時にそのプロパティ修飾子の型を使用することができません。

import QtQuick

Item {
    property int xxx
    Item on xxx { ... }
}

この警告を修正するには、on を削除するか、有効なプロパティ修飾子型を使用してください:

import QtQuick

Item {
    property int xxx
    Item { ... }

    // Alternative: use a valid property modifier type
    NumberAnimation on xxx { ... }
}

文字列からの構築は非推奨です。代わりに構造化された値型の構築を使用してください。

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

文字列を使用してQML_STRUCTURED_VALUE を構築しました。

これはなぜ悪いのですか?

これは非推奨であり、タイプミスを起こしやすい。

import QtQuick

Item {
    property point p: "5, 6"
}

この警告を修正するには、プロパティに文字列をバインドする代わりに、QML_STRUCTURED_VALUE の説明に従って構造化値型を設定します:

import QtQuick

Item {
    property point p: ({ x: 5, y: 6 })
}

戻り値の型アノテーションがない関数が返される

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

戻り値の型アノテーションがない関数から値を返しました。

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

何も返さないように関数をアノテーションしたのですから、関数は何も返してはいけません。QMLツールはこのメソッドを処理できず、QMLエンジンは将来のQtバージョンでは戻り値を無視します。

import QtQuick

Item {
    function f(x: int) {
        ...
        return x
    }
}

この警告を修正するには、関数のシグネチャを新しい戻り値の型に合わせるか、戻り値を削除してください:

import QtQuick

Item {
    function f(x: int): int {
        ...
        return x
    }
    function alternativeF(x: int) {
        ...
        return
    }
}

バインディング/オブジェクト/リテラルを代入できません

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

オブジェクト、リテラル、式を互換性のない型のプロパティにバインドしました。

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

QMLエンジンは実行時にオブジェクトやリテラル、式を代入することができません。

import QtQuick

Item {
    property date xxx: 42
}

この警告を修正するには、互換性のある型のオブジェクト、値、式をバインドしてください:

import QtQuick

Item {
    property date xxx: new Date()
}

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