1
votes

So, if I figure out this correctly, QGraphicsItem are (abstract) graphics items which belong to one QGraphicsScene (which is scene manager basically).

QGraphicsView is specific "view" into that scene and multiple views can view same scene.

If I were to have 3 views viewing on same scene, where one view views 1-5/10 items, other 5-10/10 and third view views all of them, I would need to have one scene and three views with some kind of filters which items to draw. Is this possible ?

How can I filter which QGraphicsItems are displayed in specific QGraphicsView?

1

1 Answers

2
votes

It's not possible to do directly, but is rather easy with viewscenes (akin to viewmodels).

Item visibility is an integral part of the scene, not a view. This makes sense: once you start letting scenes change item properties, there's never a sane place where one might stop. Next you want to move items a bit, etc. So this simply isn't supported in the current design.

You can have a prototype scene that has all items, and then viewscenes (viewmodels) that have copies of the items you wish visible. The items are small and cheap to copy, so even with a thousand items in a scene, the cost to implement it that way is minuscule. Just make a factory to make copies of all item types you're interested in, and run them on the prototype scene, ignoring the items you wish not shown.