def contextMenuEvent(self, event):
        """ Creates and executes the context menu for the tree view
        """
        menu = QtWidgets.QMenu(self)

        for action in self.actions():
            menu.addAction(action)

        openAsMenu = self.createOpenAsMenu(parent=menu)
        menu.insertMenu(self.closeItemAction, openAsMenu)

        menu.exec_(event.globalPos())
def contextMenuEvent ( self , event ) : menu = QtWidgets . QMenu ( self ) for action in self . actions ( ) : menu . addAction ( action ) openAsMenu = self . createOpenAsMenu ( parent = menu ) menu . insertMenu ( self . closeItemAction , openAsMenu ) menu . exec_ ( event . globalPos ( ) )
Creates and executes the context menu for the tree view