Ok thanks I took a closer look and I don't know how I managed to miss that the QPoint was being passed as an argument. Anyway just in case anyone else gets hung up on this here is and example of some code that works.

Qt Code:
  1. from PyQt4 import QtGui, QtCore
  2. import sys
  3.  
  4.  
  5. class Test(QtGui.QTableWidget):
  6. def __init__(self):
  7. super(Test, self).__init__(5,5)
  8. # If you comment out these lines the contextMenuEvent slot will be
  9. # called when the context menu is suppose to appear. If you leave them
  10. # active the ctxMenu def is called when the context Menu is suppose
  11. # to appear
  12. self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
  13. self.customContextMenuRequested.connect(self.ctxMenu)
  14.  
  15. def contextMenuEvent(self, event):
  16. menu = QtGui.QMenu(self)
  17. a = QtGui.QAction("Current Cell", self)
  18. menu.addAction(a)
  19. a.triggered.connect(self.contextCurPosEvent)
  20. self.cursor_zero = event.pos()
  21. menu.exec_(event.globalPos())
  22.  
  23. def ctxMenu(self, position):
  24. menu = QtGui.QMenu(self)
  25. a = QtGui.QAction("Current Cell", self)
  26. menu.addAction(a)
  27. a.triggered.connect(self.contextCurPos)
  28. self.cursor_zero = position
  29. # Because the QTable Widget is a scroll area the position passed to
  30. # this def is actually with respect to the viewport of the widget
  31. # therefore you need to call the mapToGlobal from the viewport and not
  32. # the TableWidget
  33. menu.exec_(self.viewport().mapToGlobal(position))
  34.  
  35. def contextCurPosEvent(self):
  36. pos = self.cursor_zero
  37. col = self.columnAt(pos.x())
  38. row = self.rowAt(pos.y())
  39. print('Map From Cursor %d, %d' % (row, col))
  40. model_idx = self.model().createIndex(row, col)
  41.  
  42. model_idx = self.currentIndex()
  43. print('From Current Index %d, %d' % (model_idx.row(), model_idx.column()))
  44. print('\n')
  45.  
  46. def contextCurPos(self):
  47. pos = self.cursor_zero
  48. col = self.columnAt(pos.x())
  49. row = self.rowAt(pos.y())
  50. print('Map From Cursor %d, %d' % (row, col))
  51. model_idx = self.model().createIndex(row, col)
  52.  
  53. model_idx = self.currentIndex()
  54. print('From Current Index %d, %d' % (model_idx.row(), model_idx.column()))
  55. print('\n')
  56.  
  57. app = QtGui.QApplication(sys.argv)
  58. x = Test()
  59. x.show()
  60. sys.exit(app.exec_())
To copy to clipboard, switch view to plain text mode