이 페이지에서

중복 바인딩

qmllint에서는 이 경고 범주를 ' [duplicate-property-binding] '로 표기합니다.

속성에 중복된 인터셉터

무슨 일이 발생했나요?

하나의 속성에 여러 개의 인터셉터가 있습니다.

이것이 왜 문제인가요?

동일한 속성에 여러 인터셉터를 설정하는 것은 QML 엔진에서 지원되지 않습니다.

예시

Behavior 를 동일한 속성에 두 번 인터셉터로 사용해 보겠습니다:

import QtQuick

Rectangle {
    Behavior on width {
        NumberAnimation { duration: 1000 }
    }
    Behavior on width { // not ok: Duplicate interceptor on property "width" [duplicate-property-binding]
        NumberAnimation { duration: 2000 }
    }
}

이 경고를 해결하려면 Behavior 중 하나를 제외한 나머지를 모두 제거하십시오:

import QtQuick

Rectangle {
    Behavior on width {
        NumberAnimation { duration: 2000 }
    }
}

‘속성 수정자 유형’항목도 참조하십시오.

속성의 값 소스가 중복됨

무슨 일이 발생했나요?

하나의 속성에 여러 값 소스가 있습니다.

이것이 왜 문제일까요?

값 소스들이 결합되면 예상치 못한 동작이 나타납니다. 아래 예제를 참조하십시오.

예시

동일한 속성에 ` NumberAnimation `을 값 소스로 두 번 사용해 봅시다:

import QtQuick

Rectangle {
    NumberAnimation on x { to: 50; duration: 1000 }
    NumberAnimation on x { to: 10; duration: 100 } // not ok: Duplicate value source on property "x" [duplicate-property-binding]

    onXChanged: console.log(x)
}

해당 프로그램의 출력 결과를 확인해 보면, 두 개의 ` NumberAnimation `가 서로 교차하여 출력되는 것을 볼 수 있는데, 이는 의도한 효과가 아닐 것입니다. 이 경고를 해결하려면 ` NumberAnimation` 중 하나를 제외한 나머지를 모두 제거하십시오:

import QtQuick

Rectangle {
    NumberAnimation on x { to: 50; duration: 1000 }
}

값 소스와 바인딩을 결합할 수 없음

무슨 일이 일어난 것일까요?

한 속성에 동일한 속성에 대해 값 소스와 바인딩이 모두 지정되어 있습니다.

왜 문제가 될까요?

바인딩은 값 소스가 해당 속성을 업데이트하기 시작하기 전에 속성 값을 먼저 업데이트하게 됩니다. 이로 인해 예기치 않은 동작이 발생할 수 있으며, 코드 가독성도 떨어집니다.

예시

동일한 속성에 ` NumberAnimation `을 값 소스로 사용해 봅시다:

import QtQuick

Rectangle {
    NumberAnimation on x { to: 50; duration: 1000 } // not ok: Cannot combine value source and binding on property "x" [duplicate-property-binding]
    x: 55

    onXChanged: console.log(x)
}

해당 프로그램의 출력 결과를 확인해 보면, ` NumberAnimation `가 55에서 50으로 애니메이션되는 것을 볼 수 있습니다. 다음 코드를 사용하면 더 읽기 쉬울 것입니다:

import QtQuick

Rectangle {
    NumberAnimation on x { from: 55; to: 50; duration: 1000 } // ok: intentions are clearer now!
}

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