folibis
folibis

Reputation: 12864

Change origin point of QPainter

By default QPainter has its origin point in top-left corner. I want to draw shapes but all coordinates that I have are in cartesian system. So my question - how can I change the origin point to bottom-left corner? Sure, I can scale(1,-1) but then drawText() also scaled and prints inverted text. All I nee it just move origin point.

Upvotes: 2

Views: 4954

Answers (2)

Marek R
Marek R

Reputation: 37697

QPainter painter(this);

painter.translate(this.rect().bottomLeft());
painter.scale(1.0, -1.0);

Upvotes: 4

Maxim Makhun
Maxim Makhun

Reputation: 2231

You can use void QPainter::translate ( const QPointF & offset ) method to change origin coordinate. Check docs here.

Upvotes: 3

Related Questions