QGraphicsItem::scale() bug or not ?
Hi,
After some googling around I found a way to mirror items along X as well as Y axis. It was very simple infact,
Code:
item->scale(-1.0,1.0); //mirror along y axis
item->scale(1.0,-1.0); //mirror along y axis
That worked fine except that the item left junk when mirrored , especially when the item was not symmetric about origin. Adding an update() before the scale solved the problem. I'm using qt 4.3 on kubuntu.
Is this a qt bug for sure ? (safe to double confirm :p )
Re: QGraphicsItem::scale() bug or not ?
What does the bounding rect of the item look like?
1 Attachment(s)
Re: QGraphicsItem::scale() bug or not ?
Here goes the screenshot ! The grayed item is mirrored inappropriately!
EDIT: BTW I'm using Qt4.2.3 not Qt 4.3. I'm sorry. :(
Re: QGraphicsItem::scale() bug or not ?
You didn't answer my question, but I already see the problem is indeed in the bounding rect. It's not symmetric, so when you mirror, only the new bounding rect is being redrawn and it doesn't contain parts of the "old" position. It might be called a bug, but I wouldn't count on fixing it. A solution might be to invalidate and redraw the part of the scene that causes the problem or use QTransform instead of a negative scale :)
Re: QGraphicsItem::scale() bug or not ?
Quote:
Originally Posted by
wysota
You didn't answer my question, but I already see the problem is indeed in the bounding rect.
I thought the screenshot was what you asked for. I'm drawing a rect with boundingRect() dim when selected. Well the horizontal axis is along the node (red circle). You asked how does the bounding rect look like right ?
Quote:
It's not symmetric, so when you mirror, only the new bounding rect is being redrawn and it doesn't contain parts of the "old" position. It might be called a bug, but I wouldn't count on fixing it. A solution might be to invalidate and redraw the part of the scene that causes the problem or use QTransform instead of a negative scale :)
Thanks for explaining me in detail. :) But shouldn't Item::setMatrix method do an update() and then reflect the change ? (I haven't yet checked qt code , so correct me if i'm wrong)
And as for QTransform is concerned, my app should be compatible with Qt 4.2 :(
Re: QGraphicsItem::scale() bug or not ?
Yes, but it updates the new bouningRect.
Re: QGraphicsItem::scale() bug or not ?
Re: QGraphicsItem::scale() bug or not ?
Quote:
Originally Posted by
wysota
A solution might be to invalidate and redraw the part of the scene that causes the problem or use QTransform instead of a negative scale :)
I couldn't find anything related to mirroring in QTRansform. Can somebody give me a hint ?