blob: be8a375a4f41f921802f62154816ae5844cdc939 [file] [log] [blame]
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\example simple-cpp
\title Qt 3D: Simple C++ Example
\ingroup qt3d-examples-cpp
\brief A C++ application that demonstrates how to render a scene in Qt 3D.
\image simple-cpp.png
\e {Simple} demonstrates how to render a scene in Qt 3D.
\include examples-run.qdocinc
\section1 Setting Up the Scene
We set up the scene in the \e main.cpp file.
To be able to use the classes and functions in the Q3D Core, Q3D Render,
Qt 3D Input, and Qt 3D Extras modules, we must include the classes:
\quotefromfile simple-cpp/main.cpp
\skipto Qt3DCore
\printuntil QTorusMesh
First, we set up the scene and specify its root entity:
\skipto createScene()
\printuntil {
\skipto rootEntity
\printuntil ;
We specify the material to use for Phong rendering:
\skipto QPhongMaterial
\printuntil ;
The root entity is just an empty shell and its behavior is defined by the
components that it references. We specify the torus entity and its mesh,
transform, and material components:
\skipto torusEntity
\printuntil material
We also specify a sphere entity and its components:
\skipto sphereEntity
\printuntil material
We use a property animation to animate the sphere transform.
Finally, we initialize a Qt GUI application that uses a Qt 3D window:
\skipto int
\printuntil }
*/