Rotation QML Type
提供一种旋转项目的方法。更多
| Import Statement: | import QtQuick |
属性
- angle : real
- axis
- distanceToPlane : real
(since 6.11) - origin
详细说明
旋转类型提供了一种通过旋转类型变换来旋转Item 的方法。
它允许(z 轴)相对于任意点旋转,还提供了一种为项目指定类似 3D 旋转的方法。与rotation 属性相比,它对项目旋转的控制能力更强。
下面的示例围绕内部点(25,25)旋转了一个矩形:
Rectangle { width: 100; height: 100 color: "blue" transform: Rotation { origin.x: 25; origin.y: 25; angle: 45} }
对于类似 3D 的项目旋转,除了原点外,还必须指定旋转轴。下面的示例显示了应用于Image 的各种类 3D 旋转。
import QtQuick Row { x: 10; y: 10 spacing: 10 Image { source: "images/qt-logo.png" } Image { source: "images/qt-logo.png" transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 18 } } Image { source: "images/qt-logo.png" transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 36 } } Image { source: "images/qt-logo.png" transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 54 } } Image { source: "images/qt-logo.png" transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 72 } } }

另请参阅 表盘控件示例和Qt Quick Demo - Clocks。
属性文档
angle : real
旋转角度,单位为顺时针度数。
axis group
旋转轴。对于简单的(2D)绕点旋转,无需指定轴,因为默认轴是 z 轴 (axis { x: 0; y: 0; z: 1 })。
对于典型的 3D 旋转,通常需要指定原点和轴。

distanceToPlane : real [since 6.11]
该属性定义了透视投影模型中视图平面(虚拟屏幕)与观察者之间的距离。
距离越小,透视效果越强,使物体在旋转过程中后退或前进的幅度更大。数值越大,透视效果越平直,透视失真越不明显。
默认值为1024.0 ,它提供了适中的透视效果,适合大多数使用情况。
当此属性设置为0 时,不会应用透视投影。在这种情况下,将使用QMatrix4x4::rotate() 定义的变换直接在三维空间中进行旋转。
该属性只影响绕 x 轴和 y 轴的旋转。围绕 Z 轴的旋转(2D 旋转)不受此属性影响。
此属性在 Qt 6.11 中引入。
origin group
旋转的原点(即当项目的其他部分旋转时,相对于父项目固定不变的点)。默认情况下,原点为 (0,0)。
© 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.