PDA

View Full Version : QGraphicsView + rotate around axis ?



medved6
24th May 2010, 10:27
Hi All

I'm trying to rotate my scene with several Items. I'm looking at the scene and I want rotate the scene around some point( point equal to centerTo idealy ).



void MyGraphicsView::updateTransform()
{
QTransform tr;
tr.rotate(m_yRotate/1.0, Qt::YAxis);
tr.rotate(m_xRotate/1.0, Qt::XAxis);
tr.translate(some_point.x(), some_point.y());
setTransform(tr);
/**/
}


In other words how can I change the position of YAxis or/and XAxis during such transform?
So far rotation is done around some Axis I can not controll.

I've tryed to play with:

translate
setTransformationAnchor(QGraphicsView::NoAnchor);
setResizeAnchor(QGraphicsView::NoAnchor);
setAlignment();


Any ideas ?

Thank you!

tbscope
24th May 2010, 11:16
You translate the coordinate system before you rotate around the new coordinate system

medved6
24th May 2010, 18:46
I belive I do that.
In the code above I do tr.translate(some_point.x(), some_point.y());

Some point - is point I want rotation around. But it seems like it does not work.

tbscope
24th May 2010, 19:30
No, you rotate first and then do a translation.
Try putting the translate before the two rotates and see what happens.

Or to be more clear: the transformations are performed in the order you write them.

medved6
25th May 2010, 04:30
Thank you! I've tryed that.
Does not make any difference:(
The scene is still rotates around some "other" axis.
What elese could I do ?