Given 4 points being be the result of
QPolygon poly = transform.mapToPolygon(QRectF(0, 0, 1, 1));
how can I find QTransform transform? (Even better: also given an arbitrary source rectangle)
Motivation: Given the four corner points of an image to be drawn in a perspectively distorted coordinate system, how can I draw the image using QPainter?

This is a screenshot illustrating the problem in GIMP, where one can transform a layer by moving around the 4 corners of the layer. This results in a perspective transformation. I want to do exactly the same in a Qt application. I know that QTransform is not restricted to affine transformations but can also handle perspective transformations.
You should be able to do this with
QTransform.squareToQuad. Just pass it theQPolygonFyou want to transform to.I’ve sometimes had some issues getting squareToQuad to do what I want, and have had to use
QTransform.quadToQuadinstead, defining my own starting quad, but you might have more luck.