Qt3D Reference Documentation

QML Viewport Element

The Viewport item defines the logical viewport for a 3D scene. It includes all necessary references and parameters for the contents of the scene, as well as drawing and painting functions More...

This element was introduced in Qt3D 4.8.

Properties

Detailed Description

The Viewport item is usually the outermost in a 3D scene, specifying the size of the view, the camera position, lights, and the main 3D object:

 import QtQuick 1.0
 import Qt3D 1.0

 Viewport {
     width: 640; height: 480
     camera: Camera {}
     light: Light {}
     Item3D {
         mesh: Mesh { source: "meshes/teapot.bez" }
         effect: Effect {}
     }
 }

See also Camera.

Property Documentation

blending : bool

The blending property is used to enable or disable GL_BLEND on the viewport, for alpha blending of drawn objects.

By default, blending is set to false.

See also Effect::blending.


camera : Camera

This property sets the camera parameters which will be used for the appropriate viewing transforms in OpenGL. The default is a perspective camera with its eye located at (0, 0, 10) looking at the center (0, 0, 0), with the y axis as up.


fovzoom : bool

This property is used to set or unset zooming based on field-of-view (fov). Normally zooming is achieved by moving the camera physically closer to the target object. This options achieves zooming by narrowing or broadening the fov.

By default, fov zooming is set to false.


light : Light

This property defines the main scene light to use for 3D items that are drawn in this viewport.

See also lightModel.


lightModel : LightModel

The user is able to set a lighting model for the 3d environment through the use of the lightModel property. By default the light model is undefined.

See also light.


navigation : bool

This property is used to set or unset camera navigation in for the viewport. Camera navigation allows the user to move the camera position around using the mouse.

By default, camera navigation is set to true.


picking : bool

User interaction in QML/3d is handled through the concept of object picking. Each item has a unique picking id which is queried for a given screen click position when the mouse is clicked.

If this property is set to true, picking will be supported for this viewport, while if the property is false, no picking will be applied.

The default value for this property is false.

See also showPicking.


showPicking : bool

The underlying mechanism for picking is based on painting an off-screen buffer with a flat coloured image containing all of the objects with a unique color value.

Setting this property to true will display this flat-colour picking representation in the viewport, which can be useful for debugging problems with object selection.

The default value for this property is false.

See also picking.


showSceneGraph : bool

This property controls whether or not the 3D scenegraph structure is dumped to the console when the viewport is first rendered. Studying the output can be very useful for optimising the scene, and for detecting issues with rendering, such as misplaced textures, materials, geometry and so on.

By default the value is set to false.