PDA

View Full Version : drawing series of rotated ellipses



qtn00b
16th December 2009, 19:14
Hi!

I'm trying to draw a bunch of rotated ellipses, but I'm not getting the results I want.

I have a class subclassing QGraphicsItem. In the paint function, let's say I want to draw an ellipse (width: 6, height 2) rotated at 10 degrees, 20 degrees and 30 degrees at 3 different locations. How would I do that? I've tried the following, but I don't think my understanding of rotate is quite right.

painter->rotate(-10);
painter->drawEllipse(location1, 6, 2);
painter->rotate(+10);

painter->rotate(-20);
painter->drawEllipse(location2, 6, 2);
painter->rotate(20);

painter->rotate(-30);
painter->drawEllipse(location3, 6, 2);
painter->rotate(30);


Thanks for any help you can provide!

mirelon
17th December 2009, 01:51
QGraphicsEllipseItem* ellipse = new QGraphicsEllipseItem();
ellipse->rotate(...);
ellipse->paint(painter);


See QGraphicsEllipseItem documentation for supplied methods like rotate, setPos, ...