PDA

View Full Version : Ignoring zoomin/zoom out in the GraphicsView



maverick_pol
18th July 2007, 14:09
Hi guys,

I have added a custom scene to the QGraphicsView object. Then I have create some items and added them to the scene. I do a lot of zooming in the graphicsview using:
QGraphicsView::scale(...)

This solution scales the whole QgraphicsView(changes the coordinate system, as you know). But I want my items not to change their sizes while zooming.

How Can I create some items in the scene/view that are ignoring the scaling?

Beforehand thanks.

Maverick

marcel
18th July 2007, 14:35
Use QGraphicsItem::setFlag(QGraphicsItem::ItemIgnoresT ransformations).

Regards

maverick_pol
18th July 2007, 16:43
Hi,

I have already used this solution. Items do not change their sizes, but while zoomin in/out as the xy coordinates change, items' position does the same. They move to the center(while zooming in)...etc

Any other suggestions?

Maverick

marcel
18th July 2007, 17:38
But this seems normal behavior.
If you really want fixed drawing, then do it in drawForeground or drawBackground for the view.

Another way is to compute the scale factor and adjust the positions of the items you want fixed.

Regards

maverick_pol
19th July 2007, 08:10
HI,

Do you mean that, when I draw my "items" in the drawBackground/drawForeground of the QGraphicsView while zooming their position and size will not change? I was thinking about doing as you have said, but wasn't sure if it works..
Have you tested this?

Thank you for your reply and idea

Maverick

aamer4yu
20th July 2007, 06:42
One simple way of doing it is...
use QAbstractSlider::setTracking ( bool enable )... it wont emit the change in signal until u release the slider...
Hope this will solve ur problem :)