2010-01-19

Let Children of QGraphicsItemGroup handle their own event

QGraphicsItem can have its own child QGraphicsItem objects. However, QGraphicsItem has no API (like setItems) to add its child. It is only possible allow the child attach to the parent, like
QGraphicsItemGroup, a subclass of QGraphicsItem, allows to add and remove children
But a very very important function, we must pay attention to:
If "enabled=true", QGraphicsItemGroup will handle all the events. For example, the event of mouse click on the child item won't be handled by child item.

If "enabled=false", QGraphicsItem Group will not block the child item's event and let child item handle it own event.

4 comments:

  1. OMG, this has been driving me nuts for months! Thanks!

    ReplyDelete
  2. one more possible reason
    http://bugreports.qt.nokia.com/browse/QTBUG-15477

    ReplyDelete
  3. You are a life-saver, thank you so much!

    ReplyDelete