Class: QgsSingleItemModel

A QAbstractItemModel subclass which contains a single read-only item.

Added in version 3.26.

Class Hierarchy

Inheritance diagram of qgis.core.QgsSingleItemModel

Base classes

QAbstractItemModel

QObject

class qgis.core.QgsSingleItemModel[source]

Bases: QAbstractItemModel

__init__(parent: QObject | None = None, text: str | None = '', data: Dict[int, Any] = {}, flags: Qt.ItemFlags | Qt.ItemFlag = Qt.NoItemFlags)

Constructor for QgsSingleItemModel with the specified parent object and display text.

The data map specifies the data which should be returned for the specified roles, where map keys are Qt item roles.

Custom flags can also be specified for the item.

Parameters:
  • parent (Optional[QObject] = None)

  • text (Optional[str] = '')

  • data (Dict[int, Any] = {})

  • flags (Union[Qt.ItemFlags, Qt.ItemFlag] = Qt.NoItemFlags)

__init__(parent: QObject | None, columnData: Any, flags: Qt.ItemFlags | Qt.ItemFlag = Qt.NoItemFlags)

Constructor for a multi-column QgsSingleItemModel with the specified parent object.

The columnData list specifies the data which should be returned for the specified roles for each column in the model, where each entry in the list must be a QMap of Qt item role to value.

Custom flags can also be specified for the item.

Parameters:
  • parent (Optional[QObject])

  • columnData (Any)

  • flags (Union[Qt.ItemFlags, Qt.ItemFlag] = Qt.NoItemFlags)