本页内容

XrItem QML Type

3D 空间中一个可承载 2D 用户界面内容的虚拟表面。更多...

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

Node

Status: Technology preview

此类型处于技术预览阶段,可能会有变动。

属性

详细说明

XrItem 类型是一个Qt Quick 3D Node ,它表示一个具有width 和height 的矩形。它包含一个Qt Quick Item ,该对象由contentItem 指定,并将其缩放以适应容器。这提供了一种便捷的方式,可将传统的 2D 用户界面显示在具有真实世界尺寸的虚拟表面上。

XrItem 的任何其他子项都将被视为 Node 的普通子项,不会进行缩放。

例如,以下代码将创建一个 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 计算出的宽度。

另请参阅 automaticHeight 。

color : color [default: "white"]

此属性定义了XrItem 的背景色。

contentItem : Item

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

另请参阅 pixelsPerUnit 。

height : real

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

另请参阅 width 。

manualPixelsPerUnit : bool [default: false]

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

另请参阅 pixelsPerUnit 。

pixelsPerUnit : real

该属性决定了 contentItems 的 2D 坐标系中多少像素会对应于XrItem 的 3D 坐标系中的一个单位。默认情况下,该值是根据内容项的大小和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.