code: def addHeaderContextMenu(self, checked = None, checkable = None, enabled = None):
          
          checked = checked if checked is not None else {}
          checkable = checkable if checkable is not None else {}
          enabled = enabled if enabled is not None else {}
  
          horizontal_header = self.horizontalHeader()
          horizontal_header.setContextMenuPolicy(Qt.ActionsContextMenu)
  
          self.toggle_column_actions_group = QtWidgets.QActionGroup(self)
          self.toggle_column_actions_group.setExclusive(False)
          self.__toggle_functions = []  # for keeping references
  
          for col in range(horizontal_header.count()):
              column_label = self.model().headerData(col, Qt.Horizontal, Qt.DisplayRole)
              #logger.debug("Adding: col {}: {}".format(col, column_label))
              action = QtWidgets.QAction(str(column_label),
                                     self.toggle_column_actions_group,
                                     checkable = checkable.get(column_label, True),
                                     enabled = enabled.get(column_label, True),
                                     toolTip = "Shows or hides the {} column".format(column_label))
              func = self.__makeShowColumnFunction(col)
              self.__toggle_functions.append(func) # keep reference
              horizontal_header.addAction(action)
              is_checked = checked.get(column_label, not horizontal_header.isSectionHidden(col))
              horizontal_header.setSectionHidden(col, not is_checked)
              action.setChecked(is_checked)
              action.toggled.connect(func)
docs: Adds the context menu from using header information
  
              checked can be a header_name -> boolean dictionary. If given, headers
              with the key name will get the checked value from the dictionary.
              The corresponding column will be hidden if checked is False.
  
              checkable can be a header_name -> boolean dictionary. If given, header actions
              with the key name will get the checkable value from the dictionary. (Default True)
  
              enabled can be a header_name -> boolean dictionary. If given, header actions
              with the key name will get the enabled value from the dictionary. (Default True)