O'Reilly logo

Qt 5 Projects by Marco Piccolino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Previewing Qt 3D entities in QML

The qmlscene tool that we used in the last chapter can also be used here to quickly visualize our Qt 3D QML code as soon as we write it. In order to achieve this, you just need a little boilerplate code. Just create a file called Preview3D.qml in the gui subfolder and fill it in with the following code:

// Preview3D.qmlimport QtQuick.Scene3D 2.0import Qt3D.Core 2.0import Qt3D.Render 2.0import Qt3D.Extras 2.0Scene3D {    id: scene3d    Entity {        id: sceneRoot        Element {}        Camera {            id: camera            projectionType: CameraLens.PerspectiveProjection            fieldOfView: 45            nearPlane : 0.1            farPlane : 1000.0            position: Qt.vector3d( 5.0, 5.0, 5.0 )            upVector: Qt.vector3d( 0.0, 1.0, 0.0 )            viewCenter: Qt.vector3d( 0.0, 0.0, 0.0 )        } components: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required