无法将 Qt3DCore::Quick::Quick3DEntity 分配给 QQmlComponent
Unable to assign Qt3DCore::Quick::Quick3DEntity to QQmlComponent
正在尝试向自定义 Qt3D 实体添加类委托 属性:
MyEntity.qml:
Entity {
id: root
default property Entity delegate // <-- MyEntity.qml:26
property int n: 1
property matrix4x4 t
NodeInstantiator {
id: rep
model: root.n
delegate: Entity {
components: [
Transform {
matrix: {
var m = root.t
for(var i = 1; i < rep.index; i++)
m = m.times(root.t)
return m
}
}
]
NodeInstantiator {
delegate: root.delegate
}
}
}
}
用法:
MyEntity {
t: Qt.matrix4x4(
1, 0, 0, 0.1,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
)
n: 5
Entity {...}
}
结果:
qrc:/MyEntity.qml:26:17: 无法将 Qt3DCore::Quick::Quick3DEntity 分配给 QQmlComponent
属性声明:
default property Entity delegate
必须改为:
default property Component delegate
才能正常工作。
正在尝试向自定义 Qt3D 实体添加类委托 属性:
MyEntity.qml:
Entity {
id: root
default property Entity delegate // <-- MyEntity.qml:26
property int n: 1
property matrix4x4 t
NodeInstantiator {
id: rep
model: root.n
delegate: Entity {
components: [
Transform {
matrix: {
var m = root.t
for(var i = 1; i < rep.index; i++)
m = m.times(root.t)
return m
}
}
]
NodeInstantiator {
delegate: root.delegate
}
}
}
}
用法:
MyEntity {
t: Qt.matrix4x4(
1, 0, 0, 0.1,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
)
n: 5
Entity {...}
}
结果:
qrc:/MyEntity.qml:26:17: 无法将 Qt3DCore::Quick::Quick3DEntity 分配给 QQmlComponent
属性声明:
default property Entity delegate
必须改为:
default property Component delegate
才能正常工作。