Rotation QML Type
提供一种旋转项目的方法。更多
Import Statement: | import QtQuick |
属性
详细说明
旋转类型提供了一种通过旋转类型变换来旋转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: "pics/qt.png" } Image { source: "pics/qt.png" transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 18 } } Image { source: "pics/qt.png" transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 36 } } Image { source: "pics/qt.png" transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 54 } } Image { source: "pics/qt.png" transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 72 } } }
另请参阅 表盘控件示例和Qt Quick Demo - Clocks。
属性文档
angle : real |
要旋转的角度(顺时针方向)。
要旋转的轴。对于围绕点的简单(2D)旋转,无需指定轴,因为默认轴是 z 轴 (axis { x: 0; y: 0; z: 1 }
)。
对于典型的 3D 旋转,通常需要指定原点和轴。
© 2025 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.