May 2019
Intermediate to advanced
542 pages
13h 37m
English
Being able to return the data is only one piece of a model's functionality. Models also need to be able to provide other information, such as the names of the column headers or the appropriate method for sorting the data.
To implement header data in our model, we need to create a headerData() method:
def headerData(self, section, orientation, role): if ( orientation == qtc.Qt.Horizontal and role == qtc.Qt.DisplayRole ): return self._headers[section] else: return super().headerData(section, orientation, role)
headerData() returns data on a single header given three pieces of information—the section, orientation, and role.
Headers can be either vertical or horizontal as determined by the orientation argument, which ...
Read now
Unlock full access