부착된 속성 재사용
qmllint에서는 이 경고 범주를 ‘ [attached-property-reuse] ’으로 표기합니다.
상위 범위에서 이미 초기화된 첨부된 타입 사용
무슨 일이 발생했나요?
전파되는 첨부 타입 을 여러 번 초기화했습니다.
참고: 이 문제는 주로 QQuickAttachedPropertyPropagator 를 상속하는 첨부형에서 발생합니다.
왜 문제가 될까요?
전파되는 부속 객체는 인스턴스화될 때마다 메모리를 소모하지만, 실제로는 한 번만 초기화하면 됩니다.
예시
import QtQuick
import QtQuick.Templates as T
import QtQuick.Controls.Material // contains the Material attached type
T.ToolBar {
id: control
// first instantiation of Material's attached property
property color c: Material.toolBarColor
background: Rectangle {
// second instantiation of Material's attached property, wrong!
color: Material.toolBarColor
}
}이 경고를 해결하려면 부모에서 부착된 타입을 조회하십시오:
import QtQuick
import QtQuick.Templates as T
import QtQuick.Controls.Material // contains the Material attached type
T.ToolBar {
id: control
// first instantiation of Material's attached property
property color c: Material.toolBarColor
background: Rectangle {
// use control's attached property, correct!
color: control.Material.toolBarColor
}
}© 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.