QPainter painter; painter.resetTransform(); // Resets the transform matrix to identity painter.drawLine(0, 0, 100, 100); // Draws a line from (0,0) to (100,100)
QPainter painter; painter.translate(50, 50); // Translates the coordinate system by (50,50) painter.resetTransform(); // Resets the transform matrix to identity painter.drawRect(0, 0, 100, 100); // Draws a rectangle with top-left corner at (0,0)
QPainter painter; painter.setPen(Qt::red); // Sets the pen color to red painter.drawLine(0, 0, 100, 100); // Draws a line from (0,0) to (100,100) painter.resetTransform(); // Resets the transform matrix to identity painter.setPen(Qt::blue); // Sets the pen color to blue painter.drawLine(0, 0, 50, 200); // Draws a line from (0,0) to (50,200)In all of these examples, the QPainter object has its transform matrix reset to the identity matrix using the resetTransform function. This causes subsequent drawing operations to use the default coordinate system, without any transformations applied. These examples are part of the Qt GUI library, specifically the QPainter class.