QObjectRegistryRef Class
このクラスは、C++コードからObjectRegistry というQML型に登録されたオブジェクトにアクセスするために使用されます。詳細...
| ヘッダー: | #include <QObjectRegistryRef> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS QmlDesignSupport) target_link_libraries(mytarget PRIVATE Qt6::QmlDesignSupport) |
| qmake: | QT += qmldesignsupport |
| 以下のように: | Qt 6.12 |
| QMLでは: | MultiObjectRegistryRef およびObjectRegistryRef |
| 継承元: | QAbstractObjectRegistryRef |
- 継承されたメンバーを含む全メンバーの一覧
- QObjectRegistryRefは、Qt Qml の設計サポート用C++クラス群の一部です。
プロパティ
- object : QObject*
パブリック関数
| QObjectRegistryRef(QObject *parent = nullptr) | |
| QObjectRegistryRef(QQmlEngine *engine, QObject *parent = nullptr) | |
| QObjectRegistryRef(QQmlEngine *engine, const QString &key, QObject *parent = nullptr) | |
| QObject * | object() const |
シグナル
| void | objectChanged(QObject *object) |
再実装された保護関数
| virtual bool | event(QEvent *event) override |
詳細な説明
使用例:
// 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()));関連項目: ObjectRegistry およびQAbstractObjectRegistryRef::key 。
プロパティのドキュメント
[read-only] object : QObject*
このプロパティは、このインスタンスが参照するオブジェクトを保持します。
同じキーで複数のオブジェクトが登録されている場合、このインスタンスが参照するオブジェクトは、それらのうちいずれか(特定されない)となります。その場合は、代わりに `QMultiObjectRegistryRef ` を使用してください。
アクセス関数:
| QObject * | object() const |
Notifierシグナル:
| void | objectChanged(QObject *object) |
ObjectRegistry およびQAbstractObjectRegistryRef::keyも参照してください 。
メンバ関数のドキュメント
[explicit] QObjectRegistryRef::QObjectRegistryRef(QObject *parent = nullptr)
parent を使用して、QObjectRegistryRefのインスタンスを作成します。
注: このコンストラクタは、キーが設定された際に正しい QML エンジンが自動的に解決される場合にのみ使用してください 。通常、C++ からこのクラスのインスタンスを作成する際には、このようなことは起こりません。QML エンジンのポインタをパラメータとして受け取るコンストラクタのいずれかを使用することを推奨します。
qmlEngine() およびQAbstractObjectRegistryRef::keyも参照してください 。
[explicit] QObjectRegistryRef::QObjectRegistryRef(QQmlEngine *engine, QObject *parent = nullptr)
QMLのengine およびparent を使用して、QObjectRegistryRefのインスタンスを生成します。すべての登録は、指定されたQMLエンジンにスコープが限定されます。
QAbstractObjectRegistryRef::keyも参照してください 。
[explicit] QObjectRegistryRef::QObjectRegistryRef(QQmlEngine *engine, const QString &key, QObject *parent = nullptr)
QMLのengine 、key 、およびparent を使用して、QObjectRegistryRefのインスタンスを生成します。すべての登録は、指定されたQMLエンジンにスコープが限定されます。
QAbstractObjectRegistryRef::keyも参照してください 。
[override virtual protected] bool QObjectRegistryRef::event(QEvent *event)
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.