Expression painter:rect() returns a Qt variant of class =qt.QRect representing the pixel coordinates of the drawing surface. This does not depend on the transformation matrix but corresponds to the default coordinate system set by painter:initmatrix().

The same information can be obtained more conveniently using function painter:currentsize() or properties painter.width and painter.height.