title: Double right-click listener for a QTableWidget
body: <p>I have a PyQt5 QTableWidget for which I want to detect double-right-click events.</p>
  
  <p>Here is my 'design.py' module:</p>
  
  <pre><code>from PyQt5 import QtCore, QtWidgets
  
  class Ui_MainWindow(object):
      def setupUi(self, MainWindow):
          MainWindow.setObjectName("MainWindow")
          MainWindow.resize(790, 472)
          self.centralwidget = QtWidgets.QWidget(MainWindow)
          self.centralwidget.setObjectName("centralwidget")
          self.tbwMain = QtWidgets.QTabWidget(self.centralwidget)
          self.tbwMain.setGeometry(QtCore.QRect(0, 0, 801, 451))
          self.tbwMain.setObjectName("tbwMain")
          self.tabBoxes = QtWidgets.QWidget()
          self.tabBoxes.setObjectName("tabBoxes")
          self.horizontalLayoutWidget = QtWidgets.QWidget(self.tabBoxes)
          self.horizontalLayoutWidget.setGeometry(QtCore.QRect(0, 0, 791, 421))
          self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget")
          self.horizontalLayout = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget)
          self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
          self.horizontalLayout.setObjectName("horizontalLayout")
          spacerItem = QtWidgets.QSpacerItem(220, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
          self.horizontalLayout.addItem(spacerItem)
          self.tblBoxes = QtWidgets.QTableWidget(self.horizontalLayoutWidget)
          self.tblBoxes.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
          self.tblBoxes.setVerticalScrollMode(QtWidgets.QAbstractItemView.ScrollPerPixel)
          self.tblBoxes.setRowCount(1)
          self.tblBoxes.setObjectName("tblBoxes")
          self.tblBoxes.setColumnCount(3)
          item = QtWidgets.QTableWidgetItem()
          self.tblBoxes.setHorizontalHeaderItem(0, item)
          item = QtWidgets.QTableWidgetItem()
          self.tblBoxes.setHorizontalHeaderItem(1, item)
          item = QtWidgets.QTableWidgetItem()
          self.tblBoxes.setHorizontalHeaderItem(2, item)
          item = QtWidgets.QTableWidgetItem()
          item.setTextAlignment(QtCore.Qt.AlignCenter)
          self.tblBoxes.setItem(0, 0, item)
          item = QtWidgets.QTableWidgetItem()
          item.setTextAlignment(QtCore.Qt.AlignCenter)
          self.tblBoxes.setItem(0, 1, item)
          item = QtWidgets.QTableWidgetItem()
          item.setTextAlignment(QtCore.Qt.AlignCenter)
          self.tblBoxes.setItem(0, 2, item)
          self.tblBoxes.horizontalHeader().setStretchLastSection(True)
          self.tblBoxes.verticalHeader().setVisible(False)
          self.horizontalLayout.addWidget(self.tblBoxes)
          spacerItem1 = QtWidgets.QSpacerItem(220, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
          self.horizontalLayout.addItem(spacerItem1)
          self.tbwMain.addTab(self.tabBoxes, "")
          MainWindow.setCentralWidget(self.centralwidget)
          self.statusbar = QtWidgets.QStatusBar(MainWindow)
          self.statusbar.setObjectName("statusbar")
          MainWindow.setStatusBar(self.statusbar)
          self.retranslateUi(MainWindow)
          self.tbwMain.setCurrentIndex(0)
          QtCore.QMetaObject.connectSlotsByName(MainWindow)
  
      def retranslateUi(self, MainWindow):
  
          # - - - - -
          self.tblBoxes.doubleClicked.connect(self.tblMouseDoubleClick)
  
      def tblMouseDoubleClick(self):
          pass #Get event somehow?
  
  if __name__ == "__main__":
      import sys
      app = QtWidgets.QApplication(sys.argv)
      MainWindow = QtWidgets.QMainWindow()
      ui = Ui_MainWindow()
      ui.setupUi(MainWindow)
      MainWindow.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>As well as my 'main.py' module:</p>
  
  <pre><code>from PyQt5 import QtCore, QtGui, QtWidgets
  from design import Ui_MainWindow
  import shared.components.tables as tbl
  from unshared import boxes as bxs
  import switch as swb
  
  stop_threads = False
  
  class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
      def __init__(self, *args, **kwargs):
          QtWidgets.QMainWindow.__init__(self, *args, **kwargs)
          self.setupUi(self)
          load(self)
      def mouseDoubleClickEvent(self, QMouseEvent):
          if event.type() == QtCore.QEvent.MouseButtonPress:
              if event.button() == QtCore.Qt.RightButton:
                  print('Double right-click!')
  
  if __name__ == "__main__":
      import sys
      app = QtWidgets.QApplication(sys.argv)
      w = MainWindow()
      w.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>I've tried setting up the event by using <code>mouseDoubleClickEvent</code> in the main.py module; however, the clicks only register when clicking in areas of the main window outside of the table. </p>
  
  <p>I've also considered using connect (as shown in design.py), but I don't know how to check to see if the right mouse button is being clicked without the mouse event - and I'm not sure if it is possible for me to get the mouse event. I just want to make it so that when the user double-right-clicks on a cell in my table (<code>tblBoxes</code>) I can detect the event.</p>
  
  <p>Is this possible with either of the methods I've proposed? I'm using Qt Designer, so the less invasive the solution the better.</p>