Nesta página

QObjectRegistryRef Class

Essa classe é usada para acessar um objeto registrado com um tipo QML d ObjectRegistry o a partir do código C++. Mais...

Cabeçalho: #include <QObjectRegistryRef>
CMake: find_package(Qt6 REQUIRED COMPONENTS QmlDesignSupport)
target_link_libraries(mytarget PRIVATE Qt6::QmlDesignSupport)
qmake: QT += qmldesignsupport
Desde: Qt 6.12
No QML:MultiObjectRegistryRef e ObjectRegistryRef
Herda de: QAbstractObjectRegistryRef

Propriedades

Funções públicas

QObjectRegistryRef(QObject *parent = nullptr)
QObjectRegistryRef(QQmlEngine *engine, QObject *parent = nullptr)
QObjectRegistryRef(QQmlEngine *engine, const QString &key, QObject *parent = nullptr)
QObject *object() const

Sinais

void objectChanged(QObject *object)

Funções protegidas reimplementadas

virtual bool event(QEvent *event) override

Descrição detalhada

Exemplo 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()));

Veja também ObjectRegistry e QAbstractObjectRegistryRef::key.

Documentação da propriedade

[read-only] object : QObject*

Esta propriedade contém o objeto ao qual esta instância faz referência.

Se vários objetos estiverem registrados com a mesma chave, o objeto referenciado por esta instância será um deles, não especificado. Nesse caso, use ` QMultiObjectRegistryRef `.

Funções de acesso:

QObject *object() const

Sinal do notificador:

void objectChanged(QObject *object)

Veja também ` ObjectRegistry ` e ` QAbstractObjectRegistryRef::key`.

Documentação da função membro

[explicit] QObjectRegistryRef::QObjectRegistryRef(QObject *parent = nullptr)

Cria uma instância de `QObjectRegistryRef` com ` parent`.

Observação: Use este construtor somente se o mecanismo QML correto for resolvido automaticamente quando a chave for definida. Isso geralmente não ocorre ao criar uma instância desta classe a partir de C++. Recomenda-se usar um dos construtores que recebem um ponteiro para o mecanismo QML como parâmetro.

Veja também qmlEngine() e QAbstractObjectRegistryRef::key.

[explicit] QObjectRegistryRef::QObjectRegistryRef(QQmlEngine *engine, QObject *parent = nullptr)

Cria uma instância de `QObjectRegistryRef` com os arquivos QML engine e parent. Todos os registros estão restritos ao mecanismo QML especificado.

Veja também QAbstractObjectRegistryRef::key.

[explicit] QObjectRegistryRef::QObjectRegistryRef(QQmlEngine *engine, const QString &key, QObject *parent = nullptr)

Cria uma instância de QObjectRegistryRef com os arquivos QML engine, key e parent. Todos os registros estão restritos ao mecanismo QML especificado.

Veja também 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.