在本页

XrItem QML Type

三维空间中可容纳二维用户界面内容的虚拟表面。更多

Import Statement: import QtQuick3D.Xr
Since: Qt 6.8
Inherits:

Node

属性

详细说明

XrItem 类型是一个Qt Quick 3DNode ,用widthheight 表示一个矩形。它容纳一个Qt Quick Item ,由contentItem 指定,并按比例调整。这提供了一种方便的方法,可以将传统的 2D 用户界面显示在具有真实世界大小的虚拟表面上。

XrItem 的其他子节点将被视为节点的普通子节点,不会进行缩放。

例如,以下代码将创建一个 1 米乘 1 米的虚拟表面,其内容项的尺寸为 600 像素乘 600 像素。请注意,这里的效果是通过缩放内容项而不是以更高分辨率渲染内容项来实现的。

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

属性文档

automaticHeight : bool [default: "false"]

当设置为 true 时,XrItem 将忽略通过 height 属性设置的高度,并使用从contentItem 高度计算的高度。

另请参阅 automaticWidth

automaticWidth : bool [default: "false"]

当设置为 true 时,XrItem 将忽略通过 width 属性设置的宽度,而使用从contentItem width 计算出的宽度。

另请参阅 automaticHeight

color : color [default: "white"]

该属性定义了XrItem 的背景颜色。

contentItem : Item

此属性包含将在虚拟表面上显示的内容项。内容项的大小将用于计算单位像素值,并根据该内容项的大小进行缩放。

另请参阅 pixelsPerUnit

height : real

该属性定义了XrItem 在 3D 坐标系中的高度。

另请参阅 width

manualPixelsPerUnit : bool [default: false]

如果该属性为true ,则内容项的 2D 坐标系与该XrItem 的 3D 坐标系之间的比率由pixelsPerUnit 的值定义。如果该属性为false ,则比率根据内容项的大小和XrItem 的大小计算。

另请参阅 pixelsPerUnit

pixelsPerUnit : real

该属性决定了XrItem 的三维坐标系的一个单位中能容纳内容项二维坐标系中多少像素。默认情况下,该值是根据内容项的大小和XrItem 的大小计算得出的。

设置manualPixelsPerUnit 可禁用默认行为,并手动设置单位像素值。

另请参阅 manualPixelsPerUnit

width : real

该属性定义了XrItem 在 3D 坐标系中的宽度。

另请参阅 height

© 2026 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.