[Interest] Qt3D/QML How to access a QTransform based property from C++

Volker Enderlein volker.enderlein at ifm-chemnitz.de
Wed Aug 30 12:09:40 CEST 2017


Thanks Guiseppe,

I try to come up with a solution based on your and Sean's answer.

Cheers Volker

Am 30/08/2017 um 11:29 schrieb Giuseppe D'Angelo:
> 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,
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest


-- 
Volker Enderlein                         Institut für Mechatronik e.V.
Phone: +49 (0)371 531 19651              Reichenhainer Strasse 88
Fax:   +49 (0)371 531 19699              D-09126 Chemnitz
Mail: volker.enderlein at ifm-chemnitz.de   www.ifm-chemnitz.de

Vorstand:
Prof. Dr.-Ing. Welf-Guntram Drossel (Vorsitz)
Dipl.-Ing. Heiko Freudenberg (Geschäftsführer)

Amtsgericht Chemnitz VR 713
Ust.-IdNr. DE 159285348




More information about the Interest mailing list