PDA

View Full Version : Non scalable items, any idea?



maverick_pol
16th July 2007, 13:33
I have a quick question. I am using the QGraphicsView framework(qt 4.3). I have a map drawn on the scene and need to scale it. But I have also created other items which should not be scaled. When I scale the map(QGraphicsView::scale(...)) I need that items not to change their sizes and coordinates.
[CODE] QGraphicsItem::setFlat(....ItemIgnoresTransformati on)[CODE] works "almost" fine as my items do not change their sizes, but they change their coordinates.
How can I scale the scene but set some items not to change their coordinates? Is it possible?.

Any idea how the achieve the effect I need?


Beforehand thanks.

Maverick

guilugi
17th July 2007, 09:01
Well, you could use mapping methods to do this

1) You obtain your item' initial coordinates mapped in viewport coordinates (with scene->mapToScene / viewport->mapFromScene)

2) You store them in a QPoint

3) Each time you apply a transformation to the scene, you can always restore the old item position since you have it in viewport coordinates...with inverse mapping :)


Don't know if I am clear, and I don't know if it actually works (not tested) ! :p