QObjectRegistryRef Class
Esta clase se utiliza para acceder desde código C++ a un objeto registrado con un tipo QML de « ObjectRegistry ». Más información...
| Cabecera: | #include <QObjectRegistryRef> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS QmlDesignSupport) target_link_libraries(mytarget PRIVATE Qt6::QmlDesignSupport) |
| qmake: | QT += qmldesignsupport |
| Desde: | Qt 6.12 |
| En QML: | MultiObjectRegistryRef y ObjectRegistryRef |
| Heredan de: | QAbstractObjectRegistryRef |
- Lista de todos los miembros, incluidos los heredados
- QObjectRegistryRef forma parte de las clases de C++ de soporte al diseño de «Qt Qml ».
Propiedades
- object : QObject*
Funciones públicas
| QObjectRegistryRef(QObject *parent = nullptr) | |
| QObjectRegistryRef(QQmlEngine *engine, QObject *parent = nullptr) | |
| QObjectRegistryRef(QQmlEngine *engine, const QString &key, QObject *parent = nullptr) | |
| QObject * | object() const |
Señales
| void | objectChanged(QObject *object) |
Funciones protegidas reimplementadas
| virtual bool | event(QEvent *event) override |
Descripción detallada
Ejemplo de uso:
// 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()));Véase también ObjectRegistry y QAbstractObjectRegistryRef::key.
Documentación de la propiedad
[read-only] object : QObject*
Esta propiedad contiene el objeto al que hace referencia esta instancia.
Si hay varios objetos registrados con la misma clave, el objeto al que hace referencia esta instancia es uno cualquiera de entre ellos, sin especificar cuál. En ese caso, utiliza en su lugar ` QMultiObjectRegistryRef `.
Funciones de acceso:
| QObject * | object() const |
Señal del notificador:
| void | objectChanged(QObject *object) |
Véase también ObjectRegistry y QAbstractObjectRegistryRef::key.
Documentación de funciones de miembro
[explicit] QObjectRegistryRef::QObjectRegistryRef(QObject *parent = nullptr)
Crea una instancia de `QObjectRegistryRef` con ` parent`.
Nota: Utiliza este constructor solo si el motor QML correcto se resuelve automáticamente al establecer la clave. Por lo general, esto no ocurre al crear una instancia de esta clase desde C++. Se recomienda utilizar uno de los constructores que aceptan un puntero al motor QML como parámetro.
Véase también ` qmlEngine()` y ` QAbstractObjectRegistryRef::key`.
[explicit] QObjectRegistryRef::QObjectRegistryRef(QQmlEngine *engine, QObject *parent = nullptr)
Crea una instancia de `QObjectRegistryRef` con el motor QML engine y parent. Todos los registros se limitan al motor QML especificado.
Véase también QAbstractObjectRegistryRef::key.
[explicit] QObjectRegistryRef::QObjectRegistryRef(QQmlEngine *engine, const QString &key, QObject *parent = nullptr)
Crea una instancia de `QObjectRegistryRef` con los elementos QML engine, key y parent. Todos los registros tienen como ámbito el motor QML especificado.
Véase también QAbstractObjectRegistryRef::key.
[override virtual protected] bool QObjectRegistryRef::event(QEvent *event)
Reimplementa: ` 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.