Hello,

your self must be your widget and you may need two more lines. Example with a copy from tableview:
Qt Code:
  1. self.ui.tableView.copyAction = QtGui.QAction('&Copy', self.ui.tableView)
  2. self.ui.tableView.copyAction.setShortcutContext(QtCore.Qt.WidgetShortcut)
  3. self.ui.tableView.copyAction.setShortcut(QtCore.Qt.CTRL + QtCore.Qt.Key_C)
  4. self.ui.tableView.copyAction.setStatusTip('Copy to the Clipboard')
  5. self.ui.tableView.addAction(self.ui.tableView.copyAction)
  6. self.ui.tableView.copyAction.triggered.connect(self.copy)
To copy to clipboard, switch view to plain text mode