QTransform transform; transform.rotateRadians(1.57); // 90 degrees in radians QPointF point(10, 10); point = transform.map(point); // Rotate the point by 90 degrees qDebug() << point; // Should output (10, -10)
QTransform transform; transform.rotateRadians(0.785); // 45 degrees in radians QPainter painter(this); painter.setTransform(transform); // Set the painter transform painter.drawLine(0, 0, 100, 100); // Draw a lineIn this example, we create a QTransform and rotate it by 45 degrees using rotateRadians() function. Then we create a QPainter object and set the transform using setTransform() function. Finally, we draw a line using drawLine() function. The line will be rotated by 45 degrees due to the painter transform. The QTransform class is part of the QtGui package library.