중복 바인딩
이 경고 카테고리의 철자는 [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! }
© 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.