Change origin point of QPainter

走远了吗. 提交于 2019-12-11 02:07:17

问题


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.


回答1:


QPainter painter(this);

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



回答2:


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



来源:https://stackoverflow.com/questions/24014090/change-origin-point-of-qpainter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!