Embedding a Qt 3D scene into a Qt Quick form

Now let's see how we can perform the opposite task. This approach is useful if your application is built mainly around Qt Quick. This means that you use the QQmlApplicationEngine class in the main() function, and the root object of your main.qml file is usually the Window object. It's very easy to extend your Qt Quick application with a bit of 3D action.

We could place all the code into the main.qml file, but it's more convenient to split it because setting up a 3D scene requires quite a bit of code. Let's say you have a file named My3DScene.qml that contains the usual content of a 3D scene:

Entity {    components: [        RenderSettings {            activeFrameGraph: ForwardRenderer { /*...*/ }, InputSettings {} ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.