[Interest] Qt3D: Create custom meshes and textures in C++, use in QML

Oleg Evseev ev.mipt at gmail.com
Thu Jul 6 11:50:56 CEST 2017


Hi, Helmut

I'm not sure I understand your problem in a right way, but I think my
setData example from https://bugreports.qt.io/browse/QTBUG-60429 maybe
helpful.

> Or is it possible to construct some of these in C++ and use them in QML
via setContextProperty: Buffer, Geometry, GeometryRenderer or other classes
from the Qt3D modules?

>From my point of view it would be better to construct them (Buffer,
Geometry, GeometryRenderer, Textures and so on) in C++ and use them also in
C++. Just make some of "using" functions Q_INVOKABLE to have ability to
call them from QML when need it.
Also you can "get access" to certain entities through Q_PROPERTY for QML
GUI.

---
With regards, Oleg.

2017-07-06 12:09 GMT+03:00 Helmut Mülner <helmut.muelner at gmail.com>:

> After studying the (spare) Qt3d documentation and examples and researching
> almost all Web resources, I am still not sure how to best solve the
> following task:
>
>
>
> I have to create custom meshes and textures in C++ (the data come from a
> database) and I want to use these items in a QML GUI.
>
> At run-time I want to change or replace the meshes and/or textures.
>
>
>
> For other items (models and other QObjects) I use QQmlContext::
> setContextProperty.
>
> I also use image providers.
>
>
>
> The answer to https://stackoverflow.com/questions/38847357/use-qt3d-qentity-in-qml-scene3d shows how to do this with qmlRegisterType  … and a class derived from Qt3DCore::QEntity.
>
> I cannot do the addComponent in the constructor, so I would have to use slots do add and replace components that are called from QML.
>
> Replacements would have to use QEntity::components(), removeComponent and addComponent.
>
>
>
> Will this work, and is this the best strategy?
>
>
>
> Or is it possible to construct some of these in C++ and use them in QML via setContextProperty: Buffer, Geometry, GeometryRenderer or other classes from the Qt3D modules?
>
>
>
> Is anybody out there who has experience with that?
>
>
>
> Regards,
>
>
>
> Helmut
>
>
>
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170706/f51a9257/attachment.html>


More information about the Interest mailing list