Il 30/08/2017 10:07, Volker Enderlein ha scritto:
Entity {
      id: root

      property Transform frame: Transform {}
      property Material mat: PhongMaterial { diffuse: Qt.rgba(0.8, 0.8,
0.8, 1.0) }
...

}

Later I try to update the Transform and Material from C++. But I cannot
set the properties via qmlEntity->setProperty("Transform",
QVariant(Qt3DCore::QTransform)); because QTransform is not usable as
metatype.

The type of the property is QTransform*, not QTransform -- pass a pointer to your QTransform object to setProperty. (Also, the name of the property is "frame", not "Transform".)

IOW:

Qt3DCore::QTransform *t = ...;
entity->setProperty("frame", t);

How would I do that, or should I use an entirely different approach?

Another approach is exposing the QTransform to the QML engine (for instance via engine->setContextProperty("_myTransform", t)), then using _myTransform in QML:

Entity {
    components: [ _myTransform, ... ]
}


Hope this helps,
--
Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
KDAB - Qt, C++ and OpenGL Experts

Attachment: smime.p7s
Description: Firma crittografica S/MIME

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to