En esta página

Reutilización de propiedades adjuntas

qmllint escribe esta categoría de advertencia como « [attached-property-reuse] ».

Se está utilizando un tipo asociado que ya se ha inicializado en un ámbito superior

¿Qué ha pasado?

Has inicializado un tipo adjunto que se propaga varias veces.

Nota: Esto suele ocurrir con los tipos adjuntos que heredan de ` QQuickAttachedPropertyPropagator`.

¿Por qué es un problema?

Los objetos adjuntos propagables consumen memoria con cada instanciación, pero solo es necesario inicializarlos una vez.

Ejemplo

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
    }
}

Para solucionar esta advertencia, consulta el tipo adjunto desde el padre:

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.