호환되지 않는 유형

이 경고 카테고리의 철자는 [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 툴링은 해당 메서드를 처리할 수 없으며, 향후 Qt 버전에서 QML 엔진은 반환된 값을 무시합니다.

예제

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.