Depending on which environment you use it is different. But the scenario is the same. You need to create an event for that (extra you can calculate your mouse position to decide where to allow the right click). In Qt You can do something like following :
void xxx::onRightClick()
{
QPopupMenu* contextMenu = new QPopupMenu ( this );
Q_CHECK_PTR ( contextMenu );
contextMenu->insertItem ( "Copy" , this , SLOT (Copy()) );
contextMenu->exec ( QCursor::pos() );
delete contextMenu;
contextMenu = 0;
}
Or you can just use an event filter. You can find the documentation for doing that in Qt here: Qt documentation for mouse events.
I hope this will help you.
Regards, Mikael