Qt 3D: Simple QML Example

A QML application that demonstrates how to render a scene in Qt 3D.

../_images/simple-qml.png

Simple demonstrates how to render a scene in Qt 3D.

Running the Example

To run the example from Qt Creator , open the Welcome mode and select the example from Examples . For more information, visit Building and Running an Example.

Setting Up the Scene

We set up the entire scene in the main.qml file.

To be able to use the types in the Q3D and Q3D Render modules, we must import the modules:

The first entities we create are a Camera , which represents the camera used for the final rendering, and a camera controller, which allows us to control this camera using the keyboard or the mouse:

A RenderSettings entity specifies a ForwardRenderer as the active framegraph:

The event source is set by the Qt3DQuickWindow:

Example project @ code.qt.io