I have a class X that is a subclass of QGraphicsRectItem and I wiish to have a popup menu if the item is clicked with the right mouse button..

I'm not quite sure on how to do this.

void X::contextMenuEvent(QGraphicsSceneContextMenuEvent * event)
{
// if this is the proper way, how do I create a menu here
}

And is it defined somewhere that a rightclick generates a QGraphicsSceneContextMenuEvent ?
Or should I write code in the MousePressEvent() handler?

Anyway I would really like to know how to create the popup for the QGraphicsItem.