In questa pagina

MultiObjectRegistryRef QML Type

Questo tipo viene utilizzato per accedere agli oggetti registrati con un tip ObjectRegistry. Maggiori informazioni...

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

AbstractObjectRegistryRef

Proprietà

Segnali

Descrizione dettagliata

È possibile accedere a più oggetti registrati con la stessa chiave tramite questo riferimento.

Esempio di utilizzo:

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

Vedi anche ObjectRegistry e AbstractObjectRegistryRef::key.

Documentazione delle proprietà

objects : list<QtObject>

Questa proprietà fornisce gli oggetti a cui fa riferimento questa istanza. Non è garantito che l'ordine degli oggetti in questo elenco corrisponda all'ordine in cui sono stati registrati.

Vedi anche ObjectRegistry e AbstractObjectRegistryRef::key.

Documentazione sui segnali

objectAdded(QtObject obj)

Questo segnale viene emesso quando un nuovo oggetto, obj, è stato registrato con la chiave di questo riferimento.

Nota: il gestore corrispondente è onObjectAdded.

objectRemoved(QtObject obj)

Questo segnale viene emesso quando la registrazione di un oggetto, obj, è stata rimossa con la chiave corrispondente a questo riferimento.

Nota: se la rimozione della registrazione è stata causata dall'eliminazione dell'oggetto, il parametro obj sarà nullo poiché QML non è in grado di risolvere un oggetto in fase di eliminazione.

Nota: il gestore corrispondente è 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.