code: def tab_pressed(self, event):
          
          self.from_index = self.dock_tabbar.tabAt(event.pos())
          self.dock_tabbar.setCurrentIndex(self.from_index)
  
          if event.button() == Qt.RightButton:
              if self.from_index == -1:
                  self.show_nontab_menu(event)
              else:
                  self.show_tab_menu(event)
docs: Method called when a tab from a QTabBar has been pressed.