[Qt-interest] Rotation of a graphicsItem
Sean Harmer
sean.harmer at maps-technology.com
Mon Jun 29 15:51:23 CEST 2009
Hi,
On Monday 29 Jun 2009 10:21:49 Sujan Dasmahapatra wrote:
> Dear Friends
>
> For rotating a graphicsitem about an arbitrary point(x,y)
>
> I am doing like this
>
> geometry->translate(xc,yc);
> geometry->rotate(angle);
> geometry->translate(-xc,-yc);
>
> but its rotating about the point on the graphicsitem itself I want to
> roate it with respect to view coordinate system.what I am doing wrong
> here.
You need to map the coordinates of the point in the scene coord system about
which you wish to rotate into local item coordinates. for e.g.
// Centre of rotation in scene coords
QPointF centreScene( 0.0, 0.0 );
// Centre of rotation in item coords
QPointF centreItem = mapFromScene( centreScene );
// Do the translate, rotate, rtanslate back again thing
translate( centreItem.x(), centreItem.y() );
rotate( angle );
translate( -centreItem.x(), -centreItem.y() );
HTH,
Sean
More information about the Qt-interest-old
mailing list