Qt3D: Accessing QAspectEngine with Scene3D



  • I followed the "Writing a Custom Qt 3D Aspect" blog entry from https://www.kdab.com/writing-custom-qt-3d-aspect/. And the CustomAspect works fine.
    In that example a Qt3DQuickWindow is used. Now I want to use my custom aspect in my own project which is a QtQuick app, that uses a ApplicationWindow with a Scene3D embedded to display the Qt3D content.

    My question is: How do I access the QAspectEngine in such a case, so I can register my custom aspect?



  • I found no way to access the QAspectEngine directly, but you can register custom aspects like this:

    QT3D_REGISTER_NAMESPACED_ASPECT("customAspect", QT_PREPEND_NAMESPACE(mynamespace), CustomAspect)
    

    Then you can use this aspect in Scene3D:

    Scene3D {
        id: sceneView
        aspects: ["input", "logic", "customAspect"]
    }
    

    I had to create an unused instance of the custom aspect in my C++ code, to make it work. I guess because of the registerBackendType call in the constructor.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.