XrView QML Type

Sets up the view for an Xr application. More...

Import Statement: import QtQuick3D.Xr
Since: Qt 6.8


Status: Technical Preview




Detailed Description

An XrView sets up the view for an XR application.

// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Layouts
import QtQuick3D
import QtQuick3D.Helpers
import QtQuick3D.Xr

XrView {
    id: xrView
    XrErrorDialog { id: err }
    onInitializeFailed: (errorString) => err.run("XRView", errorString)
    referenceSpace: XrView.ReferenceSpaceLocalFloor

    xrOrigin: theOrigin

    environment: SceneEnvironment {
        clearColor: "black"
        backgroundMode: SceneEnvironment.Color

Property Documentation

depthSubmissionEnabled : bool

Gets or sets whether submitting the depth buffer to the XR compositor is enabled.

By default the value is false and the depth buffer used by the 3D scene in the XrView is not exposed to the XR compositor. However, in some platforms depth submission is implicit and cannot be disabled or controlled by the application. An example of this is VisionOS. Changing this property has no effect on those platforms. Elsewhere, with OpenXR in particular, support depends on the OpenXR implementation used at run time.

It is always safe to set depthSubmissionEnabled to true. It will just have no effect when not support by the underlying stack. Inspect the debug output to see if depth submission is in use.

Submitting the depth buffer may improve reprojections that may be performed by the XR compositor. This could happen for example when the system cannot maintain the target frame rate, and thus has to resort to predicting frame contents, in order to improve and stabilize the user's perception of the scene and reduce possibly nauseating effects. However, the application and Qt has no control over the usage of the data. It could also happen that submitting depth data has no practical effects and is simply ignored by the underlying XR runtime and compositor.

In practice submitting the depth buffer implies rendering into a depth texture provided by the XR runtime, instead of the intermediate texture/renderbuffer created and managed by Qt. This has certain lower-level consequences that can have a performance impact:

When multisample antialiasing (MSAA) is used, enabling depth submission implies rendering into a multisample depth texture and resolving the samples into the XR runtime provided non-multisample depth texture. Without depth submission, the resolve step would not be necessary at all. In addition, some 3D APIs have no support at all for resolving multisample depth-stencil data. (see the QRhi::ResolveDepthStencil flag for details) Attempts to enable depth submission in combination with MSAA will be gracefully ignored if this is the case.

Even when MSAA is not used, enabling depth submission triggers writing out depth data with 3D APIs that have control over this. The store operation for depth/stencil data is normally indicated by Qt as not necessary, which can have positive effects for performance on tiled GPU architectures in particular. With depth submission this is not done, because depth data has to then be written out always from Qt's perspective.

Note: It is recommended that developers test their applications with depth submission enabled, evaluate the advantages and disadvantages, and make a conscious choice based on their testing if they wish to enable it or not.

environment : SceneEnvironment

Holds the SceneEnvironment for the XR view.

fixedFoveation : enumeration

Controls the level of fixed foveated rendering for the XrView.

Foveated rendering reduces GPU load by reducing image quality (resolution) in areas where the difference is less perceptible to the eye. With fixed foveated rendering the areas with reduced visual fidelity are fixed and do not change. On some platforms there is no concept of, or there is no control over, fixed foveated rendering. For example, VisionOS-based devices perform dynamic, eye-tracked foveation, and thus the value of this property is ignored in practice. Whereas other devices, such as the Meta Quest 3, only have support for fixed foveation, in which case this property becomes relevant.

The value can be one of:

XrView.NoFoveation0, no foveation.
XrView.LowFoveation1, low foveation.
XrView.MediumFoveation2, medium foveation.
XrView.HighFoveation3, high foveation.

Where supported, the default is HighFoveation. Therefore, changing this value in applications should be rarely needed in practice.

isQuitOnSessionEndEnabled : bool

Holds whether the application should quit when the XR session ends.

multiViewRenderingSupported : bool

This read-only property reports the availability of Multiview Rendering.

See also multiviewRenderingEnabled.

multiviewRenderingEnabled : bool

Gets or sets whether Multiview Rendering is enabled for the XR view.

The default value is false. Changing the value to true has an effect only when multiViewRenderingSupported is true. See Multiview Rendering for details.

This property can also be used to query whether multiview rendering is really in use at run time. When not supported, the value will flip back to false.

Note: Changing the value dynamically, while the scene is already up and running, is possible, but not recommended, because enabling or disabling multiview mode involves releasing and recreating certain graphics and XR resources. Depending on the platform and headset, this then may cause visual effects that are undesirable, for example the scene may disappear and reappear.

Note: Enabling multiview rendering is recommended, in general. It can improve performance, reduce CPU and GPU load, as well as reduce power consumption. It defaults to disabled in order to ensure maximum compatibility. Developers are encouraged to verify that their application renders as expected with multiviewRenderingEnabled set to true, and then leave it set afterwards.

Certain Qt Quick and Quick 3D features that involve application-provided shader code, in particular custom 2D and 3D materials and postprocessing effects, require awareness from the developers in order to make the application-provided shader assets multiview-compatible. See Multiview Rendering for details.

See also multiViewRenderingSupported.

passthroughEnabled : bool

Holds whether passthrough is enabled for the XR view.

passthroughSupported : bool

Indicates whether passthrough is supported for the XR view.

referenceSpace : enumeration

Gets or sets the reference space for the XR view.

It can be one of:


renderStats : RenderStats

Holds rendering statistics for the XR view.

runtimeInfo : QQuick3DXrRuntimeInfo

Provides information about the XR runtime for the XR view.

xrOrigin : XrOrigin

Holds the active XR origin.

The XR origin is the point in the scene that is considered the origin of the XR coordinate system. The XR origin is used to position tracked objects like the camera and controllers in the scene. An application can have multiple XrOrigins but only one can be active at a time.

Note: This property must be set for the scene to be rendered in XR.

See also XrOrigin.

Signal Documentation


Emitted when the depthSubmissionEnabled property value changes.

Note: The corresponding handler is onDepthSubmissionEnabledChanged.


Emitted when the scene environment changes to environment .

Note: The corresponding handler is onEnvironmentChanged.


Emitted when the fixedFoveation property value changes.

Note: The corresponding handler is onFixedFoveationChanged.

initializeFailed(const QString &errorString)

Emitted when initialization fails and there is new errorString describing the failure.

Note: The corresponding handler is onInitializeFailed.


Emitted when the multiviewRenderingEnabled property value changes.

Note: The corresponding handler is onMultiviewRenderingEnabledChanged.


Emitted when passthroughEnabled property value changes.

Note: The corresponding handler is onPassthroughEnabledChanged.


Emitted when the behavior of quitting on session end changes.

Note: The corresponding handler is onQuitOnSessionEndChanged.


Emitted when the referenceSpace property value changes.

Note: The corresponding handler is onReferenceSpaceChanged.


Emitted when the session ends.

Note: The corresponding handler is onSessionEnded.


Emitted when the XR origin changes.

Note: The corresponding handler is onXrOriginChanged.

Method Documentation

vector3d processTouch(vector3d position, int pointId)

This method will search for an XrItem near position, and send a virtual touch event with touch point ID pointId if position maps to a point on the surface.

The return value is the offset between position and the touched point on the surface. This can be used to prevent a hand model from passing through an XrItem.

See also XrHandModel.

pickResult rayPick(vector3d origin, vector3d direction)

This method will "shoot" a ray into the scene starting at origin and in direction and return information about the nearest intersection with an object in the scene.

This can, for instance, be called with the position and forward vector of any object in a scene to see what object is in front of an item. This makes it possible to do picking from any point in the scene.

List<pickResult> rayPickAll(vector3d origin, vector3d direction)

This method will "shoot" a ray into the scene starting at origin and in direction and return a list of information about the nearest intersections with objects in the scene. The list is presorted by distance from the origin along the direction vector with the nearest intersections appearing first and the furthest appearing last.

This can, for instance, be called with the position and forward vector of any object in a scene to see what objects are in front of an item. This makes it possible to do picking from any point in the scene.

setTouchpoint(Item target, point position, int pointId, bool pressed)

Sends a synthetic touch event to target, moving the touch point with ID pointId to position, with pressed determining if the point is pressed. Also sends the appropriate touch release event if pointId was previously active on a different item.

object touchpointState(int pointId)

This method returns the state of the touch point with ID pointId. The state is represented by a map from property names to values:

grabbedboolIs the point grabbed by an item? If false, all other values are undefined.
targetXrItemThe item that is grabbing the touch point.
pressedboolIs the touch point pressed?
cursorPospointThe 2D position of the touch point within target
touchDistancerealThe distance from the plane to the touch point. Will be 0 if pressed is true.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.