[Qt-interest] trying to rotate ellipse

Arnold Krille arnold at arnoldarts.de
Fri Mar 18 22:59:58 CET 2011


On Friday 18 March 2011 21:34:14 Caius wrote:
> i tried painter.rotate before draw ellipse but then it didnt draw any
> ellipse.

That is because rotate() rotates the coordinate-system around the point (0,0) 
and then your ellipse was drawn outside the visible area.

The steps to draw a rotated ellipse are:
 - translate() the coordinate system to the center of the to-be-drawn ellipse
 - rotate() by the needed angle (check the docs whether it takes degree or 
radiant as argument)
 - draw your ellipse symmetrical to (0,0)

Enclose this within QPainter.save() and QPainter.restore() and the coordinate 
system is back to the original.

Have fun,

Arnold
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110318/7649b932/attachment.bin 


More information about the Qt-interest-old mailing list