Each item in the model has a set of data elements associated with it, each with its own role. The roles are used by the view to indicate to the model which type of data it needs. Custom models should return data in these types.
The general purpose roles (and the associated types) are:
Constant | Description |
---|---|
Qt.DisplayRole | The key data to be rendered in the form of text. ( QString ) |
Qt.DecorationRole | The data to be rendered as a decoration in the form of an icon. ( QColor , QIcon or QPixmap ) |
Qt.EditRole | The data in a form suitable for editing in an editor. ( QString ) |
Qt.ToolTipRole | The data displayed in the item’s tooltip. ( QString ) |
Qt.StatusTipRole | The data displayed in the status bar. ( QString ) |
Qt.WhatsThisRole | The data displayed for the item in “What’s This?” mode. ( QString ) |
Qt.SizeHintRole | The size hint for the item that will be supplied to views. ( QSize ) |
Roles describing appearance and meta data (with associated types):