[Qt-interest] Layers in Graphics Framework
Ross Bencina
rossb-lists at audiomulch.com
Tue Apr 26 13:01:54 CEST 2011
AK Wrote:
> I am trying to implement layers support for my app.
>
>
> - A item can be in one or more layer.
This sounds like an unusual situation, usually layers contain items (ie
items have only one layer)
If not for that, you could use a parent GraphicsItem for each layer (not
that it will solve your problems).
You may need to keep track of layer membership completely outside the
standard Qt framework. e.g. define your own QGraphicsItem subclass that
keeps track of which layers it is in, and only paints itself when the layer
is enabled in the current view.
You'd need to implement similar hacks for hit-testing.
> - A view displays one / more layer
> - If current display view doesn't display a layer assigned to an items,
> that item is not shown. Also its not available to hit-testing methods (
> items( QPoint etc.).
As I understand it, the Qt Graphics View framework doesn't really support
this kind of "same scene graph, render different item subsets" approach
since the state of the scene graph is exactly what is rendered. Having
different items visible in different views, but as part of the same scene
isn't directly supported (aside from supporting it in your own paint
routines, which might not be so hard, something like:
void paint(){ if( !myLayerIsVisibleInThisView() ) return; /* draw the item
*/ }
> Off course, I would not like to replicate the scene, keeping them in sync
> could be costly.
There may be inefficiencies if you _don't_ do this. For example, when you
alter items in a scene, it will generate a damage list of what regions need
to be re-rendered. This would be propogated to all views, even though the
damage would only be relevent to some views.
> What will be the best approach to achieve it???
It's a good question.. I wonder what other people think...
Ross
More information about the Qt-interest-old
mailing list