Nesta página

MultiObjectRegistryRef QML Type

Esse tipo é usado para acessar objetos registrados com o tip ObjectRegistry. Mais...

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

AbstractObjectRegistryRef

Propriedades

Sinais

Descrição detalhada

Vários objetos registrados com a mesma chave podem ser acessados por meio desta referência.

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

Veja também ObjectRegistry e AbstractObjectRegistryRef::key.

Documentação das propriedades

objects : list<QtObject>

Esta propriedade fornece os objetos aos quais esta instância faz referência. Não é garantido que a ordem dos objetos nesta lista corresponda à ordem em que foram registrados.

Veja também ObjectRegistry e AbstractObjectRegistryRef::key.

Documentação do Signal

objectAdded(QtObject obj)

Este sinal é emitido quando um novo objeto, obj, é registrado com a chave desta referência.

Observação: O manipulador correspondente é onObjectAdded.

objectRemoved(QtObject obj)

Este sinal é emitido quando o registro de um objeto, obj, é removido com a chave desta referência.

Observação: Se a remoção do registro tiver sido acionada pela exclusão do objeto, o parâmetro obj será nulo, pois o QML não consegue resolver um objeto que está sendo excluído.

Observação: O manipulador correspondente é 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.