What exactly do you want to achieve? Maybe there are better ways to do this. But if you insist on doing it this way, just create that rectangle as a QFrame and either reimplement its contextMenuEvent directly if you code by hand or install an event filter on the frame to catch its events and handle them elsewhere. With Qt4 there is also an option to use custom context menu on the frame which gives an ability to use signals and slots for handling the menu.
Bookmarks