Attached property reuse
This warning category is spelled [attached-property-reuse] by qmllint.
Using attached type already initialized in a parent scope
What happened?
You initialized a propagating attached type multiple times.
Why is this bad?
Propagating attached objects consume memory for each instantiation but only need to be initialized once.
Example
import QtQuick
import QtQuick.Templates as T
import QtQuick.Controls.Material
T.ToolBar {
id: control
property color c: Material.toolBarColor
background: Rectangle {
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
T.ToolBar {
id: control
property color c: Material.toolBarColor
background: Rectangle {
color: control.Material.toolBarColor
}
}