첨부된 속성 재사용
이 경고 범주의 철자는 [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 } }
© 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.