Something like this?

MWin inherits QMainWindow

Qt Code:
  1. bool MWin::eventFilter(QObject* object, QEvent* event) {
  2. if(event->type() == QEvent::ContextMenu) {
  3. QContextMenuEvent* mevent = static_cast<QContextMenuEvent *>(event);
  4. if(mevent->reason() == QContextMenuEvent::Mouse) {
  5. qDebug("I have blocked the context menu.");
  6. return true;
  7. } else return QObject::eventFilter(object, event);
  8. }
  9. else return QObject::eventFilter(object, event);
  10. }
To copy to clipboard, switch view to plain text mode 

and installation:

Qt Code:
  1. ...
  2. fileToolBar->installEventFilter(this);
  3. ...
  4. modeToolBar->installEventFilter(this);
  5. ...
  6. actionToolBar->installEventFilter(this);
  7. ...
To copy to clipboard, switch view to plain text mode