code: def setData(self, index, value, role=Qt.EditRole):
          
          if role != Qt.CheckStateRole and role != Qt.EditRole:
              return False
  
          treeItem = self.getItem(index, altItem=self.invisibleRootItem)
          try:
              result = self.setItemData(treeItem, index.column(), value, role=role)
              if result:
                  # Emit dataChanged to update the tree view
                  # TODO, update the entire tree?
                  # A check box can have a tristate checkbox as parent which state depends
                  # on the state of this child check box. Therefore we update the parentIndex
                  # and the descendants.
                  self.emitDataChanged(treeItem)
  
                  # Emit sigItemChanged to update other widgets.
                  self.sigItemChanged.emit(treeItem)
              return result
  
          except Exception as ex:
              # When does this still happen? Can we remove it?
              logger.warn("Unable to set data: {}".format(ex))
              if DEBUGGING:
                  raise
              return False
docs: Sets the role data for the item at index to value.
              Returns true if successful; otherwise returns false.
  
              The dataChanged and sigItemChanged signals will be emitted if the data was successfully
              set.
  
              Descendants should typically override setItemData function instead of setData()