you need to do next things:
1. set context menu policy for widget for which context menu will be displayed
Qt Code:
  1. ...
  2. m_myWidget->setContextMenuPolicy(Qt::CustomContextMenu);
  3. ...
To copy to clipboard, switch view to plain text mode 
2. connect signal customContextMenuRequested with slot in which context menu will be created
Qt Code:
  1. ...
  2. connect(m_myWidget, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(updateContextMenu(const QPoint &)));
  3. ...
To copy to clipboard, switch view to plain text mode 
3. create needed context menu and show it
Qt Code:
  1. void AnotherMyWidget::updateContextMenu(const QPoint &pos)
  2. {
  3. QMenu menu(tr("Context Menu"), this);
  4. //add actions to menu and create connections
  5. menu.exec(m_myWidget->mapToGlobal(pos));
  6. }
To copy to clipboard, switch view to plain text mode