En esta página

MultiObjectRegistryRef QML Type

Este tipo se utiliza para acceder a objetos registrados con el tip ObjectRegistry. Más información...

Import Statement: import QtQml.DesignSupport
Since: Qt 6.12
In C++: QObjectRegistryRef
Inherits:

AbstractObjectRegistryRef

Propiedades

Señales

Descripción detallada

Se puede acceder a varios objetos registrados con la misma clave a través de esta referencia.

Ejemplo de uso:

// In a QML file, register something that gets created multiple times (e.g. a repeater delegate)
Repeater {
    model: 4
    Rectangle {
        id: qmlRepeaterDelegate
        required property int index
        x: 50 * index
        width: 40
        height: 40
        MouseArea {
            property int repeaterIndex: qmlRepeaterDelegate.index
            anchors.fill: parent
            ObjectRegistry.key: "RepeatedMouseArea"
        }
    }
}

// In another QML file, refer to the registered objects
MultiObjectRegistryRef {
    id: repeaterRef
    key: "RepeatedMouseArea"

    onObjectAdded: (object)=> {
        // Connect each object's clicked signal as they are added
        object.clicked.connect(function (mouse) { clickedHandler(object); })
    }

    function clickedHandler(object) {
        console.log("Index clicked: " + object.repeaterIndex)
    }
}

Véase también ObjectRegistry y AbstractObjectRegistryRef::key.

Documentación de propiedades

objects : list<QtObject>

Esta propiedad proporciona los objetos a los que hace referencia esta instancia. No se garantiza que el orden de los objetos en esta lista coincida con el orden en que se registraron.

Véase también ObjectRegistry y AbstractObjectRegistryRef::key.

Documentación de Signal

objectAdded(QtObject obj)

Esta señal se emite cuando se ha registrado un nuevo objeto, obj, con la clave de esta referencia.

Nota: El controlador correspondiente es onObjectAdded.

objectRemoved(QtObject obj)

Esta señal se emite cuando se ha eliminado el registro de un objeto, obj, con la clave de esta referencia.

Nota: Si la eliminación del registro se ha desencadenado por la eliminación del objeto, el parámetro obj será nulo, ya que QML no puede resolver un objeto que se está eliminando.

Nota: El controlador correspondiente es ` onObjectRemoved`.

© 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.