MultiObjectRegistryRef QML Type
此类型用于访问已使用ObjectRegistry 类型注册的对象。更多内容...
| Import Statement: | import QtQml.DesignSupport |
| Since: | Qt 6.12 |
| In C++: | QObjectRegistryRef |
| Inherits: |
- 所有成员列表,包括继承的成员
- MultiObjectRegistryRef 是Qt Qml 设计支持 QML 类型的一部分。
属性
- objects : list<QtObject>
信号
- objectAdded(QtObject obj)
- objectRemoved(QtObject obj)
详细说明
通过此引用可以访问使用同一键注册的多个对象。
使用示例:
// In a QML file, register something that gets created multiple times (e.g. a repeater delegate)
Repeater {
model: 4
Rectangle {
id: qmlRepeaterDelegate
required property int index
x: 50 * index
width: 40
height: 40
MouseArea {
property int repeaterIndex: qmlRepeaterDelegate.index
anchors.fill: parent
ObjectRegistry.key: "RepeatedMouseArea"
}
}
}
// In another QML file, refer to the registered objects
MultiObjectRegistryRef {
id: repeaterRef
key: "RepeatedMouseArea"
onObjectAdded: (object)=> {
// Connect each object's clicked signal as they are added
object.clicked.connect(function (mouse) { clickedHandler(object); })
}
function clickedHandler(object) {
console.log("Index clicked: " + object.repeaterIndex)
}
}另请参阅 ObjectRegistry 和AbstractObjectRegistryRef::key 。
属性文档
objects : list<QtObject>
该属性提供由该实例引用的对象。不能保证此列表中对象的顺序与它们的注册顺序一致。
另请参阅 ObjectRegistry 和AbstractObjectRegistryRef::key 。
Signal 文档
objectAdded(QtObject obj)
当一个新对象(obj )使用此引用对应的键进行注册时,会触发此信号。
注意: 相应的处理程序 为onObjectAdded 。
objectRemoved(QtObject obj)
当对象 `obj` 的注册项被使用此引用对应的键移除时,会触发此信号。
注意:如果 注册的移除是由对象删除触发的,则obj 参数将为 null,因为 QML 无法解析正在被删除的对象。
注意: 相应的处理程序 是onObjectRemoved 。
© 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.