user20679
user20679

Reputation: 442

Non editable cell in qtableview

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.

Upvotes: 0

Views: 191

Answers (1)

titusjan
titusjan

Reputation: 5546

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

Upvotes: 1

Related Questions