[Interest] hover events on graphics scene

Ruth Ivimey-Cook ruth at ivimey.org
Mon Jun 24 15:56:15 CEST 2013


I was hoping for some help with the hover event problem - events not 
being propagated properly when there are child items - as outlined in my 
post below. Any offers?


Ruth Ivimey-Cook wrote:
> Hi
> It was suggested that I ask about this here.
> I have a graphics scene and want to monitor hover events for the items
> in the scene, but they're not getting through. I've debugged the code
> and the problem appears to be that I'm using a layered structure with
> items having child items. So:
> GraphicsScene ---+ GroupItem ---+ GraphicsItem(s)
>                    |              | GraphicsItem(s)
>                    |              \ GraphicsItem(s)
>                    |
>                    + GroupItem ---+ GraphicsItem(s)
>                    |              | GraphicsItem(s)
>                    |              \ GraphicsItem(s)
>                    |
>                    + GroupItem ---+ GraphicsItem(s)
>                                   | GraphicsItem(s)
>                                   \ GraphicsItem(s)
> I create this structure by making a group event, adding children to it,
> then adding the group to the scene. There are typically thousands of
> graphics items in each group, and I group them so that (a) the z-order
> of each group and hence each item is consistent, and (b) so that I can
> recreate, hide and show groups without needing a total redraw. In the
> real code, there are about 8 groups in all.
> It appears that the reason things don't get hover events is the code
> that looks to see if such events need reporting isn't recursive down the
> layers ( I think) but just looks at the item being added to the scene.
> But if you enable hover events on the parent (group) item, so that when
> the GraphicsItems are added to it the hover event flag is set, its
> (only) the parent group that gets the events.
> If the hover event code is thus enabled, and matches more than one item
> at a pixel location (i.e. there are several things at the same place on
> the screen) then only the first in the list seems to get the event -
> hence only the group getting events.
> A group item doesn't have a graphical appearance so IMO shouldn't ever
> receive hovers... though perhaps that's up for debate. I'd certainly
> like for the groups to ignore hovers and only have items see them.
> Any thoughts?
> Ruth

Software Manager & Engineer
Tel: 01223 414180
Blog: http://www.ivimey.org/blog
LinkedIn: http://uk.linkedin.com/in/ruthivimeycook/

More information about the Interest mailing list