本文介绍了更改 QPainter 的原点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

默认QPainter 的原点在左上角.我想绘制形状,但我拥有的所有坐标都在笛卡尔系统中.所以我的问题 - 如何将原点更改为左下角?当然,我可以 scale(1,-1) 但随后 drawText() 也可以缩放并打印反转文本.我只需要移动原点即可.

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.

推荐答案

QPainter painter(this);

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

这篇关于更改 QPainter 的原点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-19 22:04