Qt 3D▲
Qt 3D provides functionality for near-realtime simulation systems with support for 2D and 3D rendering in both Qt C++ and Qt Quick applications.
The functionality in Qt 3D is divided into the following C++ modules:
-
Qt 3D Core C++ Classes: The Qt 3D module contains functionality to support near-realtime simulation systems.
-
Qt 3D Input C++ Classes: The Qt 3D Input module provides classes for handling user input in applications using Qt3D.
-
Qt 3D Logic C++ Classes: The Qt 3D Logic module enables synchronizing frames with the Qt 3D backend.
-
Qt 3D Render C++ Classes: The Qt 3D Render module contains functionality to support 2D and 3D rendering using Qt 3D.
The following C++ modules are in still development but are available as technology previews:
-
Qt 3D Animation C++ Classes: The Qt 3D Animation modules provides a set of prebuilt elements to help you get started with Qt 3D.
-
Qt 3D Extras C++ Classes: The Qt 3D Extras module provides a set of prebuilt elements to help you get started with Qt 3D.
-
Qt 3D Scene2D C++ Classes: The Qt 3D Scene2D module provides a way to render Quick2 qml content to a Qt 3D texture.
For Qt Quick applications, Qt 3D provides the following QML modules:
-
Qt 3D Core QML Types: Provides core Qt 3D QML types.
-
Qt 3D Input QML Types: Provides QML types for Qt 3D user input.
-
Qt 3D Logic QML Types: Provides QML types to synchronize frames with the 3D backend.
-
Qt 3D Render QML Types: Provides Qt 3D QML types for rendering.
The following QML modules are in still development but are available as technology previews:
-
Qt 3D Extras QML Types: Provides Qt 3D QML types for the extras module.
-
Qt 3D Qt3DAnimation QML Types: Provides Qt 3D QML types for the animation module.
-
Qt 3D Scene2D QML Types: Provides Qt 3D QML types for the scene2d module.
-
Qt 3D Scene3D QML Types: Provides Qt 3D QML types for the Scene3D module.
Using the Module▲
For a C++ application that performs 2D or 3D rendering, collision detection, and handles user input, include the following directives of the modules' classes:
#include <Qt3DCore>
#include <Qt3DRender>
#include <Qt3DInput>
#include <Qt3DLogic>
#include <Qt3DExtras>
#include <Qt3DAnimation>
To import the QML types into your application, use the following import statement in your .qml file:
import
Qt3D.Core
import
Qt3D.Render
import
Qt3D.Input
import
Qt3D.Logic
import
Qt3D.Extras
import
Qt3D.Animation
import
QtQuick.Scene2D
import
QtQuick.Scene3D
Using a Qt module requires linking against the module library, either directly or through other dependencies. Several build tools have dedicated support for this, including CMake and qmake.
Building with CMake▲
Use the find_package() command to locate the needed module components in the Qt6 package:
find_package(Qt6 REQUIRED COMPONENTS
3
DCore
3
DRender
3
DInput
3
DLogic
3
DExtras
3
DAnimation
)
target_link_libraries(mytarget PRIVATE
Qt6::
3
DCore
Qt6::
3
DRender
Qt6::
3
DLogic
Qt6::
3
DExtras
Qt6::
3
DAnimation
)
Building with qmake▲
To configure the module for building with qmake, add the modules to the QT variable in the project's .pro file: