QObjectRegistryRef Class
Questa classe viene utilizzata per accedere, dal codice C++, a un oggetto registrato con un tipo QML di tipo " ObjectRegistry ". Per saperne di più...
| Intestazione: | #include <QObjectRegistryRef> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS QmlDesignSupport) target_link_libraries(mytarget PRIVATE Qt6::QmlDesignSupport) |
| qmake: | QT += qmldesignsupport |
| A partire da: | Qt 6.12 |
| In QML: | MultiObjectRegistryRef e ObjectRegistryRef |
| Eredita da: | QAbstractObjectRegistryRef |
- Elenco di tutti i membri, compresi quelli ereditati
- QObjectRegistryRef fa parte delle classi C++ di supporto alla progettazionQt Qml .
Proprietà
- object : QObject*
Funzioni pubbliche
| QObjectRegistryRef(QObject *parent = nullptr) | |
| QObjectRegistryRef(QQmlEngine *engine, QObject *parent = nullptr) | |
| QObjectRegistryRef(QQmlEngine *engine, const QString &key, QObject *parent = nullptr) | |
| QObject * | object() const |
Segnali
| void | objectChanged(QObject *object) |
Funzioni protette reimplementate
| virtual bool | event(QEvent *event) override |
Descrizione dettagliata
Esempio di utilizzo:
// 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()));Vedi anche ObjectRegistry e QAbstractObjectRegistryRef::key.
Documentazione delle proprietà
[read-only] object : QObject*
Questa proprietà contiene l'oggetto a cui fa riferimento questa istanza.
Se sono registrati più oggetti con la stessa chiave, l'oggetto a cui fa riferimento questa istanza è uno qualsiasi tra questi, non specificato. In tal caso, utilizzare invece QMultiObjectRegistryRef.
Funzioni di accesso:
| QObject * | object() const |
Segnale di notifica:
| void | objectChanged(QObject *object) |
Vedi anche ObjectRegistry e QAbstractObjectRegistryRef::key.
Documentazione delle funzioni membro
[explicit] QObjectRegistryRef::QObjectRegistryRef(QObject *parent = nullptr)
Crea un'istanza di `QObjectRegistryRef` con ` parent`.
Nota: utilizzare questo costruttore solo se il motore QML corretto viene risolto automaticamente quando viene impostata la chiave. Ciò generalmente non avviene quando si crea un'istanza di questa classe da C++. Si raccomanda di utilizzare uno dei costruttori che accettano come parametro un puntatore al motore QML.
Vedi anche ` qmlEngine()` e ` QAbstractObjectRegistryRef::key`.
[explicit] QObjectRegistryRef::QObjectRegistryRef(QQmlEngine *engine, QObject *parent = nullptr)
Crea un'istanza di QObjectRegistryRef con i engine i QML e parent. Tutte le registrazioni hanno come ambito il motore QML specificato.
Vedi anche QAbstractObjectRegistryRef::key.
[explicit] QObjectRegistryRef::QObjectRegistryRef(QQmlEngine *engine, const QString &key, QObject *parent = nullptr)
Crea un'istanza di QObjectRegistryRef utilizzando i file QML engine, key e parent. Tutte le registrazioni sono limitate al motore QML specificato.
Vedi anche 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.