This warning category is spelled [attached-property-reuse] by qmllint.
You initialized a propagating attached type multiple times.
Note: This mostly happens for attached types that inherit from QQuickAttachedPropertyPropagator.
Propagating attached objects consume memory for each instantiation but only need to be initialized once.
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
}
}To fix this warning, query the attached type from the parent:
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
}
}
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-6.9/qmllint-warnings-and-errors-attached-property-reuse.html