code: def mousePressEvent(self, event):
          
          if event.button() == Qt.MidButton:
              index = self.tabBar().tabAt(event.pos())
              if index >= 0:
                  self.sig_close_tab.emit(index)
                  event.accept()
                  return
          QTabWidget.mousePressEvent(self, event)
docs: Override Qt method