- Qt 6.8
- Qt Quick 3D
- QML Types
- QtQuick3D.Xr (Technical Preview)
- XrItem
- Qt Quick 3D | Commercial or GPLv3

# XrItem QML Type

A virtual surface in 3D space that can hold 2D user interface content. More...

Import Statement: | `import QtQuick3D.Xr`
Since: | Qt 6.8
Inherits: | Node
Status: | Technical Preview

- List of all members, including inherited members

## Properties

- automaticHeight : bool
- automaticWidth : bool
- color : color
- contentItem : Item
- height : real
- manualPixelsPerUnit : bool
- pixelsPerUnit : real
- width : real

## Detailed Description

The XrItem type is a Qt Quick 3D Node that represents a rectangle with width and height. It holds one Qt Quick Item, specified by contentItem, and scales it to fit. This gives a convenient way to take traditional 2D user interfaces and display them on a virtual surface that has a real world size.

Any other children of the XrItem will be treated as normal children of a Node, and will not be scaled.

For example the following code will create a virtual surface that's 1 meter by 1 meter and with a content item that's 600 pixels by 600 pixels. Note that the effect here is achieved by scaling the content item and not by rendering the content item at a higher resolution.

     XrItem {
         width: 100
         height: 100
         contentItem: Rectangle {
             width: 600
             height: 600
             color: "red"
         }
     }

## Property Documentation

automaticHeight : bool `[default: "false"]`

When set to true XrItem will ignore height set through height property and use height calculated from contentItem height.

See also automaticWidth.

automaticWidth : bool `[default: "false"]`

When set to true XrItem will ignore width set through width property and use width calculated from contentItem width.

See also automaticHeight.

color : color `[default: "white"]`

This property defines the background color of the XrItem.

contentItem : Item

This property holds the content item that will be displayed on the virtual surface. The content item's size will be used to calculate the pixels per unit value and scale based on this item's size.

See also pixelsPerUnit.

height : real

This property defines the height of the XrItem in the 3D coordinate system.

See also width.

manualPixelsPerUnit : bool `[default: false]`

If this property is `true`, the ratio between the contentItems's 2D coordinate system and this XrItem's 3D coordinate system is defined by the value of pixelsPerUnit. If this property is `false`, the ratio is calculated based on the content item's size and the size of the XrItem.

See also pixelsPerUnit.

pixelsPerUnit : real

This property determines how many pixels in the contentItems's 2D coordinate system will fit in one unit of the XrItem's 3D coordinate system. By default, this is calculated based on the content item's size and the size of the XrItem.

Set manualPixelsPerUnit to disable the default behavior and set the pixels per unit value manually.

See also manualPixelsPerUnit.

width : real

This property defines the width of the XrItem in the 3D coordinate system.

See also height.