May 2019
Intermediate to advanced
542 pages
13h 37m
English
Our model is read-only at this point, but because we're implementing a CSV editor, we need to implement writing data. To begin with, we need to override some methods to enable editing of existing data rows: flags() and setData().
flags() takes a QModelIndex value and returns a set of QtCore.Qt.ItemFlag constants for the item at the given index. These flags are used to indicate whether the item can be selected, dragged, dropped, checked, or—most interesting to us—edited.
Our method looks like this:
def flags(self, index): return super().flags(index) | qtc.Qt.ItemIsEditable
Here we're adding the ItemIsEditable flag to the list of flags returned by the parent class's flags() method, indicating that the item is ...
Read now
Unlock full access