On this page

transform2d QML Value Type

Provides transform2d type, a 2D affine transformation matrix, matching to an affine QTransform. More...

Import Statement: import QtCanvas2D
Since: Qt 6.12
Status: Technology preview

This type is in technology preview and is subject to change.

Methods

Detailed Description

A transform2d type has six values, accessible via the methods m11(), m12(), m21(), m22(), m31() and m32(). The values m11, m12, m21 and m22 scale, rotate and shear, and m31 and m32 translate.

A property of type transform2d defaults to the identity matrix, whose m11 and m22 are 1, with the other values 0.

This value type is provided by the QtCanvas2D import.

Note: Canvas2D supports only affine transforms. Perspective transforms are not supported, and when a QTransform with a perspective part is used for drawing, that part is ignored.

See also QTransform.

Method Documentation

real m11()

Returns the horizontal scaling factor.

real m12()

Returns the vertical shearing factor.

real m21()

Returns the horizontal shearing factor.

real m22()

Returns the vertical scaling factor.

real m31()

Returns the horizontal translation factor.

real m32()

Returns the vertical translation factor.

real determinant()

Returns the determinant of this transform2d.

transform2d inverted()

Returns the inverse of this transform2d if it exists, else the identity matrix.

void reset()

Resets the matrix to an identity matrix, i.e. all values are set to zero, except m11 and m22 (specifying the scale) which are set to 1.

void rotate(real angle)

Rotates the coordinate system counterclockwise by the given angle in degrees.

void rotateRadians(real angle)

Rotates the coordinate system counterclockwise by the given angle in radians.

void scale(real scale)

Scales the coordinate system by scale both horizontally and vertically.

void scale(real sx, real sy)

Scales the coordinate system by sx horizontally and sy vertically.

void setMatrix(real m11, real m12, real m21, real m22, real m31, real m32)

Sets the matrix elements to the specified values, m11, m12, m21, m22, m31 and m32. Note that this function replaces the previous values.

void shear(real sh, real sv)

Shears the coordinate system by sh horizontally and sv vertically.

transform2d times(transform2d other)

Returns the transform2d result of multiplying this transform2d with the other transform2d.

void translate(real dx, real dy)

Moves the coordinate system dx along the x axis and dy along the y axis.

© 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.