Question

Here I am again worrying about how to Zoom in and out a QGraphicsPixmapItem in a graphics scene. I looked for a direct method for this but could not find any in graphics scene or in pix map. Can someone help me with this. Do I have to extend QGraphicsPixmapItem and implement methods for this.

Thanks again for help and I really do appreciate it.

~Tharanga

Was it helpful?

Solution

QGraphicsPixmapItem inherits from QGraphicsItem, so it has all of that class's methods.

In particular, there's setScale that will change the item's scale factor (i.e. "zoom" it).

Look at the Transformations Example page for how this is done, and other transformations you can do.

OTHER TIPS

setScale() changes the size of the item, not the view scale of the scene. For a one item scene, it's effectively the same. But if you have more than one item in the scene, it changes the relation between items.

QGraphicsView::setTransform() should be used if you want to keep the item's relationship to the scene and other items.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top