Selectively omit portions of QGraphicsScene displayed by QGraphicsView

36 Views Asked by At

Let's say I have a single QGraphicsScene which contains a QGraphicsPixmapItem. I want to render this scene in two separate locations on the screen, via two separate QGraphicsViews, but in different ways:

  1. A small view of the entire image (like a minimap)
  2. A partial view of the image (i.e., only a selected area)

This partial view is not just a zoomed-in view (setSceneRect() isn't the solution). It is a view showing only parts of the QGraphicsPixmapItem that a user has selected: if in the minimap view I choose some block of pixels in the middle of the image, then on the partial view it will show just those pixels and I can zoom/pan/etc. without seeing anything else.

In the following image, you can see in the minimap the selected part of the image highlighted in red, and in the larger view, only that selected portion of the image:

Selective rendering example

Solving this problem via QGraphicsScene is trivial, which is how this is implemented in the example above. However, I want to solve this problem strictly via QGraphicsView if possible, as I'm trying to stick to a very strict MVC framework with a minimal number of data copies/versions/representations.

If that's not possible, then I will resort to using two scenes, which is less than ideal

0

There are 0 best solutions below