Rotation Element Reference

The Rotation object provides a way to rotate an Item.

[Rotation instantiates the C++ class QGraphicsRotation]

This element was introduced in Qt 4.7.

Detailed Description

The Rotation object provides a way to rotate an Item.

The Rotation object gives more control over rotation than using Item's rotation property. Specifically, it allows (z axis) rotation to be relative to an arbitrary point.

The following example rotates a Rectangle around its interior point 25, 25:

  1.                 Rectangle  {
  2.     width: 100; height: 100
  3.     color: "blue"
  4.     transform: Rotation  { origin.x: 25; origin.y: 25; angle: 45}
  5. }

Rotation also provides a way to specify 3D-like rotations for Items. For these types of rotations you must specify the axis to rotate around in addition to the origin point.

The following example shows various 3D-like rotations applied to an Image.

  1. import QtQuick 1.0
  2.  
  3. Row  {
  4.     x: 10; y: 10
  5.     spacing: 10
  6.  
  7.     Image  { source: "pics/qt.png" }
  8.     Image  {
  9.         source: "pics/qt.png"
  10.         transform: Rotation  { origin.x: 30; origin.y: 30; axis  { x: 0; y: 1; z: 0 } angle: 18 }
  11.         smooth: true
  12.     }
  13.     Image  {
  14.         source: "pics/qt.png"
  15.         transform: Rotation  { origin.x: 30; origin.y: 30; axis  { x: 0; y: 1; z: 0 } angle: 36 }
  16.         smooth: true
  17.     }
  18.     Image  {
  19.         source: "pics/qt.png"
  20.         transform: Rotation  { origin.x: 30; origin.y: 30; axis  { x: 0; y: 1; z: 0 } angle: 54 }
  21.         smooth: true
  22.     }
  23.     Image  {
  24.         source: "pics/qt.png"
  25.         transform: Rotation  { origin.x: 30; origin.y: 30; axis  { x: 0; y: 1; z: 0 } angle: 72 }
  26.         smooth: true
  27.     }
  28. }

See also QGraphicsTransform, QGraphicsItem::setRotation(), and QTransform::rotate().

Properties

Property Documentation

The angle to rotate, in degrees clockwise.

The axis to rotate around. For simple (2D) rotation around a point, you do not need to specify an axis, as the default axis is the z axis (axis { x: 0; y: 0; z: 1 }).

For a typical 3D-like rotation you will usually specify both the origin and the axis.

The origin point of the rotation (i.e., the point that stays fixed relative to the parent as the rest of the item rotates). By default the origin is 0, 0.

Notes provided by the Qt Community

No notes