Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, January 2007
Re: Can I Overlay/Display Multiple QGraphicsScenes In One QGraphicsView?


Message 1 in thread

Chris Portka wrote:
> I'm writing something that displays multiple layers of QGraphicsItems in
> one QGraphicsView.  Each of these layers has distinct properties for how
> to draw its QGraphicsItems, so I would like each layer to be its own
> QGraphicsScene.  I want to be able to overlay these scenes on top of
> each other so all the items from all scenes are displayed in one view.
>    Is there a way to do this?  I thought of just putting all the
> QGraphicsItems from all layers into one scene - but I want to be able to
> change all the items in one particular layer and leave all other items
> alone.  This corresponds perfectly with changing all the items in one
> scene, but other items from other scenes are left alone.  Displaying
> scenes on top of each other seems like an obvious feature for the
> graphics view framework, but I can't find documentation for it anywhere.
>   It looks like they specifically designed QGraphicsView to only be able
> to view one scene, why?  Am I overlooking something?  Does anybody know
> a better way of doing this?  Any help would be greatly appreciated.
> Chris

QGraphicsScene has everything you need to create a scene item: it's got a
scene rectangle, update notification for when the scene geometry or
contents change, and a paint function called render(). You can quickly toss
together a QGraphicsItem subclass that contains a QGraphicsScene instance,
and forwards the respective calls. Then create one such item for your two
scenes, and place them in a third container scene.

Andreas

-- 
 [ signature omitted ]