Hi,
In my application I have two object type. One is field item, other is composite item.
Composite items may contain two or more field items.
Here is my composite item implementation.

Qt Code:
  1. #include "compositeitem.h"
  2.  
  3. CompositeItem::CompositeItem(QString id,QList<FieldItem *> _children)
  4. {
  5. children = _children;
  6. }
  7.  
  8. CompositeItem::~CompositeItem()
  9. {
  10. }
  11.  
  12. QRectF CompositeItem::boundingRect() const
  13. {
  14. //Not carefully thinked about it
  15. return QRectF(QPointF(-50,-150),QSizeF(250,250));
  16. }
  17.  
  18. void CompositeItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
  19. {
  20. FieldItem *child;
  21. foreach(child,children)
  22. {
  23. child->paint(painter,option,widget);
  24. }
  25. }
  26.  
  27. QSizeF CompositeItem::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const
  28. {
  29. QSizeF itsSize(0,0);
  30. FieldItem *child;
  31. foreach(child,children)
  32. {
  33. // if its size empty set first child size to itsSize
  34. if(itsSize.isEmpty())
  35. itsSize = child->sizeHint(Qt::PreferredSize);
  36. else
  37. {
  38. QSizeF childSize = child->sizeHint(Qt::PreferredSize);
  39. if(itsSize.width() < childSize.width())
  40. itsSize.setWidth(childSize.width());
  41. itsSize.setHeight(itsSize.height() + childSize.height());
  42. }
  43. }
  44. return itsSize;
  45. }
  46.  
  47. void CompositeItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)
  48. {
  49. qDebug()<<"Test";
  50. }
To copy to clipboard, switch view to plain text mode 

My first question is how I can propagate context menu event to specific child.

composite1.JPG

Picture on the above demonstrates one of my possible composite item.

If you look on the code above you will see that I print "Test" when context menu event occurs.

When I right click on the line symbol I see that "Test" message is printed.
But when I right click on the signal symbol "Test" is not printed and I want it to be printed.

My second question what cause this behaviour.
How do I overcome this.