QtObject QML Type (Singleton)
基本的なQMLの型。詳細...
注意:この型はQMLのシングルトンです。この型のインスタンスはQMLエンジン内に一つしか存在しない。
プロパティ
- objectName : string
詳細説明
QtObject 型は、objectName プロパティのみを含む非ビジュアル要素です。
QtObject は、カスタムプロパティのセットを囲むための非常に軽量な型が必要な場合に便利です:
import QtQuick Item { QtObject { id: attributes property string name property int size property variant attributes } Text { text: attributes.name } }
また、単なるQObject であるため、C++ との統合にも役立ちます。詳細はQObject のドキュメントを参照してください。
プロパティのドキュメント
objectName : string
このプロパティはこの特定のオブジェクトインスタンスのQObject::objectName を保持する。
これにより、C++アプリケーションはQObject::findChild() メソッドを使って、QMLコンポーネント内のアイテムの位置を特定することができます。例えば、次の C++ アプリケーションでは、子オブジェクトRectangle の位置を特定し、そのcolor の値を動的に変更しています:
// MyRect.qml import QtQuick 2.0 Item { width: 200; height: 200 Rectangle { anchors.fill: parent color: "red" objectName: "myRect" } }
// main.cpp QQuickView view; view.setSource(QUrl::fromLocalFile("MyRect.qml")); view.show(); QQuickItem *item = view.rootObject()->findChild<QQuickItem*>("myRect"); if (item) item->setProperty("color", QColor(Qt::yellow));
© 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.