QObjectRegistryRef Class
Cette classe permet d'accéder, depuis du code C++, à un objet enregistré avec le type QML « ObjectRegistry ». En savoir plus…
| En-tête : | #include <QObjectRegistryRef> |
| CMake : | find_package(Qt6 REQUIRED COMPONENTS QmlDesignSupport) target_link_libraries(mytarget PRIVATE Qt6::QmlDesignSupport) |
| qmake : | QT += qmldesignsupport |
| Depuis : | Qt 6.12 |
| En QML : | MultiObjectRegistryRef et ObjectRegistryRef |
| Hérite de : | QAbstractObjectRegistryRef |
- Liste de tous les membres, y compris les membres hérités
- QObjectRegistryRef fait partie des classes C++ de support à la conception d'Qt Qml .
Propriétés
- object : QObject*
Fonctions publiques
| QObjectRegistryRef(QObject *parent = nullptr) | |
| QObjectRegistryRef(QQmlEngine *engine, QObject *parent = nullptr) | |
| QObjectRegistryRef(QQmlEngine *engine, const QString &key, QObject *parent = nullptr) | |
| QObject * | object() const |
Signaux
| void | objectChanged(QObject *object) |
Fonctions protégées réimplémentées
| virtual bool | event(QEvent *event) override |
Description détaillée
Exemple d'utilisation :
// Register object in a QML file
MouseArea {
ObjectRegistry.key: "MyMouseArea"
}
// In C++ code, refer to the registered object, using the QML engine you loaded the QML with
auto ref = new QObjectRegistryRef(engine, "MyMouseArea");
const auto object = ref->object();
connect(object, SIGNAL(clicked(QQuickMouseEvent*)),
this, SLOT(myClickHandler()));Voir également ObjectRegistry et QAbstractObjectRegistryRef::key.
Documentation sur les propriétés
[read-only] object : QObject*
Cette propriété contient l'objet référencé par cette instance.
Si plusieurs objets sont enregistrés avec la même clé, l'objet référencé par cette instance est l'un d'entre eux, sans que l'on sache lequel. Dans ce cas, utilisez plutôt la méthode « QMultiObjectRegistryRef ».
Fonctions d'accès :
| QObject * | object() const |
Signal de notification :
| void | objectChanged(QObject *object) |
Voir également ObjectRegistry et QAbstractObjectRegistryRef::key.
Documentation des fonctions membres
[explicit] QObjectRegistryRef::QObjectRegistryRef(QObject *parent = nullptr)
Crée une instance de `QObjectRegistryRef` avec ` parent`.
Remarque : n'utilisez ce constructeur que si le moteur QML approprié est détecté automatiquement lors de la définition de la clé. Ce n'est généralement pas le cas lors de la création d'une instance de cette classe à partir de C++. Il est recommandé d'utiliser l'un des constructeurs prenant un pointeur vers un moteur QML comme paramètre.
Voir également ` qmlEngine()` et ` QAbstractObjectRegistryRef::key`.
[explicit] QObjectRegistryRef::QObjectRegistryRef(QQmlEngine *engine, QObject *parent = nullptr)
Crée une instance de `QObjectRegistryRef` avec les éléments QML ` engine ` et ` parent`. Tous les enregistrements sont limités au moteur QML spécifié.
Voir également QAbstractObjectRegistryRef::key.
[explicit] QObjectRegistryRef::QObjectRegistryRef(QQmlEngine *engine, const QString &key, QObject *parent = nullptr)
Crée une instance de `QObjectRegistryRef` à partir des fichiers QML suivants : engine, key et parent. Tous les enregistrements sont limités au moteur QML spécifié.
Voir également QAbstractObjectRegistryRef::key.
[override virtual protected] bool QObjectRegistryRef::event(QEvent *event)
Réimplémente : QAbstractObjectRegistryRef::event(QEvent *event).
© 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.