XrInputAction QML Type
表示来自输入控制器的操作。更多...
| Import Statement: | import QtQuick3D.Xr |
| Since: | Qt 6.8 |
| Inherits: | |
| Status: | Technology preview |
此类型处于技术预览阶段,可能会发生变更。
属性
- actionId : List<enumeration>
- actionName : string
- controller : enumeration
(since 6.10) - enabled : bool
(since 6.9) - pressed : bool
- value : real
信号
详细说明
操作可以是布尔型的(例如按钮按下),也可以是模拟型的(例如摇杆轴)。
使用pressed 属性或triggered 信号来响应布尔型操作。模拟操作将设置value 属性。
注意:为 方便起见 ,模拟属性也会设置pressed 属性并发出triggered 信号,而布尔属性在被按下时会将value 设置为1.0。
以下示例演示了如何响应右手握把被按下或手部追踪中的右手捏合手势:
XrInputAction {
hand: XrInputAction.RightHand
actionId: [XrInputAction.SqueezePressed, XrInputAction.SqueezeValue, XrInputAction.IndexFingerPinch]
onTriggered: console.log("Do action here.")
}同时指定SqueezePressed 和SqueezeValue 的原因在于,部分控制器配备模拟握把按钮,而部分控制器仅配备开/关式握把开关。
属性文档
actionId : List<enumeration>
指定要响应的操作
包含一个 ID 列表,其值可以是以下之一:
| 常量 | 描述 |
|---|---|
XrInputAction.Button1Pressed | 按下按钮 1。布尔值。 |
XrInputAction.Button1Touched | 按下按钮 1。布尔值。 |
XrInputAction.Button2Pressed | 按下了按钮 2。布尔值。 |
XrInputAction.Button2Touched | 按下了按钮 2。布尔值。 |
XrInputAction.ButtonMenuPressed | 菜单按钮被按下。布尔值。 |
XrInputAction.ButtonMenuTouched | 菜单按钮被触摸。布尔值。 |
XrInputAction.ButtonSystemPressed | 系统按钮被按下。布尔值。 |
XrInputAction.ButtonSystemTouched | 系统按钮被触摸。布尔值。 |
XrInputAction.SqueezeValue | 握把按钮的按下深度。模拟值。 |
XrInputAction.SqueezeForce | 握把按钮所受的力。模拟值。 |
XrInputAction.SqueezePressed | 握把按钮被按下。布尔值。 |
XrInputAction.TriggerValue | 扳机按钮的按下深度。模拟值。 |
XrInputAction.TriggerPressed | 扳机被按下。布尔值。 |
XrInputAction.TriggerTouched | 扳机键被触碰。布尔值。 |
XrInputAction.ThumbstickX | 摇杆的X轴值。模拟值。 |
XrInputAction.ThumbstickY | 摇杆的 Y 轴值。模拟值。 |
XrInputAction.ThumbstickPressed | 摇杆被按下。布尔值。 |
XrInputAction.ThumbstickTouched | 触控摇杆被触碰。布尔值。 |
XrInputAction.ThumbrestTouched | 拇指托被触摸。布尔值。 |
XrInputAction.TrackpadX | 触控板上的 X 轴位置。模拟值。 |
XrInputAction.TrackpadY | 触控板上的 Y 轴位置。模拟值。 |
XrInputAction.TrackpadForce | 触控板上的施加力。模拟值。 |
XrInputAction.TrackpadTouched | 触控板被触摸。布尔值。 |
XrInputAction.TrackpadPressed | 触控板被按下。布尔值。 |
XrInputAction.IndexFingerPinch | 拇指与食指的捏合手势。布尔值。 |
XrInputAction.MiddleFingerPinch | 拇指与食指的捏合手势。布尔值。 |
XrInputAction.RingFingerPinch | 拇指与无名指的捏合手势。布尔值。 |
XrInputAction.LittleFingerPinch | 拇指与小指的捏合手势。布尔值。 |
XrInputAction.HandTrackingMenuPress | 手部追踪菜单手势。布尔值。 |
actionName : string
输入操作的名称。
使用此属性指定您希望响应的自定义输入操作的名称。如果已设置actionId ,则此属性无效。
controller : enumeration [since 6.10]
此输入操作将作用于的控制器。
指定要响应的控制器。
可以是以下之一:
| 常量 | 描述 |
|---|---|
XrInputAction.LeftController | |
XrInputAction.RightController | |
XrInputAction.Unknown | |
XrInputAction.LeftHand | (LeftController 的别名) |
XrInputAction.RightHand | (RightController 的别名)注意:在 Qt 6.9 中,该属性名为“hand” |
该属性在 Qt 6.10 中引入。
enabled : bool [default: true, since 6.9]
该属性决定输入操作是否会对事件做出响应。
该属性于 Qt 6.9 中引入。
pressed : bool
指示输入操作当前是否被按下。
使用此属性可检查输入操作(例如按钮)当前是否被按下。
value : real
输入操作的模拟值。
对于模拟输入(例如摇杆位置),该属性存储输入的数值(通常在 [0, 1] 范围内)。
信号文档
triggered()
当布尔操作被触发时,会发出此信号。此时,pressed 属性会被同时设置为true 。
注意: 相应的处理程序 为onTriggered 。
© 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.