PDA

View Full Version : {x,y,z}Rotation property of QGraphicsItem has gone?



Giga
9th September 2009, 05:52
Hi,
i wonder if anyone knows what happened with a great facility described at QT Blog http://labs.trolltech.com/blogs/2009/06/22/putting-a-spin-on-things

It looks like {x,y,z}Rotation property of QGraphicsItem won't reach Qt release - code from blog does not work both with 4.6-stable and trunk.

Is there any other technique you can advise to rotate QGraphicsItem instead of yRotaion + QPropertyAnimation? Is it only QGraphicsRotation + QTimeLine?

Thanks,
- Giga

wysota
9th September 2009, 08:26
QGraphicsItem::rotate()

Giga
10th September 2009, 06:28
It rotates item around z-axis, while i need either x- or y-axis rotation. That is what {x,y,z}Roration property about.

yogeshgokul
10th September 2009, 07:00
It rotates item around z-axis,
This is true.


while i need either x- or y-axis rotation
If you want a 3D rotation, you can use OpenGL.
Rotation in OpenGL is accomplished through the glRotate*() function, which is defined as:

void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
void glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);

So you can provide the axis of rotation.

You can even try it for Qt 4.6 technology preview is released.
http://qt.nokia.com/developer/qt-4.6-technology-preview

Giga
10th September 2009, 07:47
Right. glRotate*() rotates GL content, but not entire widget.
What i need is to rotate an item in graphics scene.

wysota
10th September 2009, 07:48
It rotates item around z-axis, while i need either x- or y-axis rotation. That is what {x,y,z}Roration property about.

QGraphicsItem::setTransform() and QTransform::rotate().

yogeshgokul
10th September 2009, 10:14
QGraphicsItem::setTransform() and QTransform::rotate().

QTransform class specifies 2D transformations of a coordinate system.

wysota
10th September 2009, 12:02
QTransform class specifies 2D transformations of a coordinate system.

So? Is your monitor 3D? OpenGL does 2D transformations as well. Sometimes it is worth reading more than just the first sentence of the docs.

"QTransform differs from QMatrix in that it is a true 3x3 matrix, allowing perspective transformations".