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

Helmut Mülner helmut.muelner at gmail.com
Fri Jul 7 10:28:50 CEST 2017


Hi Max,

 

I already have a „controller“ that manages some properties. I like your idea and will try it.

I think the entity could also be a property (a QEntity* or a QEntity, I am not sure) of the controller.

 

Regards,

Helmut

 

Von: max_bergmann89 at web.de [mailto:max_bergmann89 at web.de] 
Gesendet: Freitag, 7. Juli 2017 09:49
An: "Helmut Mülner" <helmut.muelner at gmail.com>
Cc: interest at qt-project.org
Betreff: Aw: Re: [Interest] Qt3D: Create custom meshes and textures in C++, use in QML

 

 

Hi Helmut,

 

      >The approach with qmlRegisterType has the problem that the object is created by QML and lives in QML space, forcing me to transfer some of the workflow logic to QML, making testing and separating GUI and backend more difficult.

 

I faced the same problem and solved it with contextProperty:

 

    QQmlApplicationEngine* engine = new QQmlApplicationEngine;
    QQmlContext* context = engine->rootContext();
    context->setContextProperty("controller", controller);    
    engine->load(QUrl(QLatin1String("qrc:/AndroidView.qml")));

 

The controller-object creates all my entities, the root entity, camera etc. In the AndroidView.qml I do:

 

    Scene3D {
        id: scene;
        anchors.fill: parent;
        aspects: ["logic", "input"];
        entity: controller.entity();
     }

 

controller.entity() returns a pointer to the root entity and everything is displayed.

 

Regards,

Max

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170707/3c724bc2/attachment.html>


More information about the Interest mailing list