[Qt-interest] trying to rotate ellipse

Sean Harmer sean.harmer at maps-technology.com
Fri Mar 18 20:46:04 CET 2011


On Friday 18 March 2011 12:11:13 caius ligarius wrote:
> Hi I am trying to rotate and ellipse using qpainter rotate fucntion but
> doesn't seem to work. Here is the code I use-
> 
> angle: ellipse orientation(0 to 360 degrees)
> cenX, cenY: ellipse centre x,y
> mjAxis, minAxis: major and minor axis of ellipse
> 
>         QPen p;
> p.setColor(color);
> p.setWidth(2);
> painter.setPen(p);
> painter.drawEllipse(QPoint(cenX, cenY), majAxis, minAxis);
> painter.rotate(angle);
> painter.restore();
> 
> It draws ellipse but doesn't rotate it by "angle" degrees, any ideas?

You need to rotate the painter before you draw the ellipse. It is too late to 
rotate it once it has already been drawn.

Sean




More information about the Qt-interest-old mailing list