Class: QgsFeatureListModel

Class Hierarchy

Inheritance diagram of qgis.gui.QgsFeatureListModel

Base classes

QSortFilterProxyModel

QAbstractProxyModel

QAbstractItemModel

QObject

QgsFeatureModel

Methods

displayExpression

featureByIndex

fidToIdx

Returns the model index corresponding to a feature ID.

fidToIndexList

idxToFid

Returns the feature ID corresponding to an index from the model.

injectNull

Returns the current state of null value injection

layerCache

Returns the vector layer cache which is being used to populate the model.

mapFromMaster

mapSelectionFromMaster

mapSelectionToMaster

mapToMaster

masterModel

onBeginInsertRows

Does nothing except for calling beginInsertRows()

onBeginRemoveRows

Does nothing except for calling beginRemoveRows()

onEndInsertRows

Does nothing except for calling endInsertRows()

onEndRemoveRows

Does nothing except for calling endRemoveRows()

parserErrorString

Returns a detailed message about errors while parsing a QgsExpression.

setDisplayExpression

setInjectNull

If True is specified, a NULL value will be injected

setSortByDisplayExpression

Sort this model by its display expression.

sortByDisplayExpression

Sort this model by its display expression.

Attributes

FeatureInfoRole

FeatureRole

FeatureWithGeometryRole

class qgis.gui.QgsFeatureListModel(sourceModel: QgsAttributeTableFilterModel | None, parent: QObject | None = None)[source]

Bases: QSortFilterProxyModel, QgsFeatureModel

class FeatureInfo
class FeatureInfo(a0: QgsFeatureListModel.FeatureInfo)

Bases: object

isEdited

True if feature has been edited.

isNew

True if feature is a newly added feature.

FeatureInfoRole = 4096
FeatureRole = 4097
FeatureWithGeometryRole = 4098
class Role

Bases: int

displayExpression(self) str[source]
Return type:

str

featureByIndex(self, index: QModelIndex, feat: QgsFeature) bool[source]
Parameters:
Return type:

bool

fidToIdx(self, fid: int) QModelIndex[source]

Returns the model index corresponding to a feature ID.

See also

idxToFid()

Parameters:

fid (int)

Return type:

QModelIndex

fidToIndexList(self, fid: int) List[QModelIndex][source]
Parameters:

fid (int)

Return type:

List[QModelIndex]

idxToFid(self, index: QModelIndex) int[source]

Returns the feature ID corresponding to an index from the model.

See also

fidToIdx()

Parameters:

index (QModelIndex)

Return type:

int

injectNull(self) bool[source]

Returns the current state of null value injection

Return type:

bool

Returns:

If a NULL value is added

layerCache(self) QgsVectorLayerCache | None[source]

Returns the vector layer cache which is being used to populate the model.

Return type:

Optional[QgsVectorLayerCache]

mapFromMaster(self, sourceIndex: QModelIndex) QModelIndex[source]
Parameters:

sourceIndex (QModelIndex)

Return type:

QModelIndex

mapSelectionFromMaster(self, selection: QItemSelection) QItemSelection[source]
Parameters:

selection (QItemSelection)

Return type:

QItemSelection

mapSelectionToMaster(self, selection: QItemSelection) QItemSelection[source]
Parameters:

selection (QItemSelection)

Return type:

QItemSelection

mapToMaster(self, proxyIndex: QModelIndex) QModelIndex[source]
Parameters:

proxyIndex (QModelIndex)

Return type:

QModelIndex

masterModel(self) QgsAttributeTableModel | None[source]
Return type:

Optional[QgsAttributeTableModel]

onBeginInsertRows(self, parent: QModelIndex, first: int, last: int)[source]

Does nothing except for calling beginInsertRows()

Deprecated since version 3.40: Use beginInsertRows() instead.

Parameters:
  • parent (QModelIndex)

  • first (int)

  • last (int)

onBeginRemoveRows(self, parent: QModelIndex, first: int, last: int)[source]

Does nothing except for calling beginRemoveRows()

Deprecated since version 3.40: Use beginRemoveRows() instead.

Parameters:
  • parent (QModelIndex)

  • first (int)

  • last (int)

onEndInsertRows(self, parent: QModelIndex, first: int, last: int)[source]

Does nothing except for calling endInsertRows()

Deprecated since version 3.40: Use endInsertRows() instead.

Parameters:
  • parent (QModelIndex)

  • first (int)

  • last (int)

onEndRemoveRows(self, parent: QModelIndex, first: int, last: int)[source]

Does nothing except for calling endRemoveRows()

Deprecated since version 3.40: Use endRemoveRows() instead.

Parameters:
  • parent (QModelIndex)

  • first (int)

  • last (int)

parserErrorString(self) str[source]

Returns a detailed message about errors while parsing a QgsExpression.

Return type:

str

Returns:

A message containing information about the parser error.

setDisplayExpression(self, expression: str | None) bool[source]
Parameters:

expression (Optional[str]) – A QgsExpression compatible string.

Return type:

bool

Returns:

True if the expression could be set, False if there was a parse error. If it fails, the old expression will still be applied. Call parserErrorString() for a meaningful error message.

setInjectNull(self, injectNull: bool)[source]

If True is specified, a NULL value will be injected

Parameters:

injectNull (bool) – state of null value injection

Note

If set to True, the sort by display expression cannot be used

setSortByDisplayExpression(self, sortByDisplayExpression: bool, order: Qt.SortOrder = Qt.AscendingOrder)[source]

Sort this model by its display expression.

Note

Not compatible with injectNull, if sorting by display expression is enabled, injectNull will automatically turned off.

Added in version 3.2.

Parameters:
  • sortByDisplayExpression (bool)

  • order (Qt.SortOrder = Qt.AscendingOrder)

sortByDisplayExpression(self) bool[source]

Sort this model by its display expression.

Added in version 3.2.

Return type:

bool