PDA

View Full Version : Parent/child transformations



jano_alex_es
22nd October 2009, 12:23
Hi,

when I transform a QGraphicsItem its childs inherit the transformation. Which flag or what can I do to skip that?

I tried setting the parent to null before applying the transformation and setting it back later, but it's applied anyway.

Please note I just want to ignore one specific transformation, so ItemIgnoresTransformations is not an option :S

thanks!

scascio
22nd October 2009, 12:33
What kind of transformation are you talking about?
Do you mean that if you rotate the parent, the child are rotated too?

Since child item geometry is relative to its parent, it is quite so normal, isn't it?

So, to fit your needs, dont use transormation built-in method and change only the shape of the parent with a method of your own.

wysota
22nd October 2009, 12:41
I'd say in such case children of the item shouldn't really be children of the item. Or the transformation has to be done not on the level of the scene but actually "inside" the item code (affecting implementations of paint(), boundingRect() and shape()).

jano_alex_es
22nd October 2009, 13:59
Maybe I can try to transform it myself... I'll try later.

thanks!

jano_alex_es
5th November 2009, 10:13
Solved.

The item I was rotating was a QGraphicsPixmapItem, so I applied the transformation to its Pixmap. The item is not rotated, just the pixmap but that's what I wanted.

Anyway, rotating the child 360 - angle of parent rotation should work fine.