Sur cette page

ObjectRegistryRef QML Type

Ce type permet d'accéder à un objet enregistré avec le typ ObjectRegistry. En savoir plus…

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

AbstractObjectRegistryRef

Propriétés

Description détaillée

Exemple d'utilisation :

// Register object in a QML file
MouseArea {
    ObjectRegistry.key: "MyMouseArea"
}

// In another QML file, refer to the registered object
ObjectRegistryRef {
    id: mouseAreaRef
    key: "MyMouseArea"

    Connections {
        target: mouseAreaRef.object
        function onClicked(mouse) {
            console.log("Mouse clicked")
        }
    }
}

Voir également ObjectRegistry et AbstractObjectRegistryRef::key.

Documentation sur les propriétés

object : QtObject [read-only]

Cette propriété spécifie l'objet référencé par cette instance.

Si plusieurs objets sont enregistrés avec la même clé, cette instance fait référence à un objet non spécifié de ce groupe. Dans ce cas, utilisez QMultiObjectRegistryRef.

Voir également ObjectRegistry et AbstractObjectRegistryRef::key.

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