0

I have a QTableView for a custom class inherited from QAbstractTableModel.

Does someone knows a way to set a particular cell of a QTableView (or the model) as non editable according to a value from another cell of the same row of the model?

Im using PySide.

Thanks in advance.

user20679
  • 442
  • 4
  • 17

1 Answers1

1

Override the flags method of the model and make sure that the ItemIsEditable is not included in the results.

For instance include this in your model class:

def flags(self, index):
    """ Returns the item flags for the given index.
    """
    return Qt.ItemIsEnabled | Qt.ItemIsSelectable
titusjan
  • 5,376
  • 2
  • 24
  • 43
  • Thanks for the suggestion. I was hoping not do something like this. The model is dynamic. Its constantly growing (in rows), so keeping track of the related indexes is going to be a problem. But it seems that I have no other alternative. – user20679 Jun 12 '17 at 13:43