Class: QgsMapLayerProxyModel

class qgis.core.QgsMapLayerProxyModel(parent: QObject = None)

Bases: PyQt5.QtCore.QSortFilterProxyModel

QgsMapLayerProxModel creates a proxy model with a QgsMapLayerModel as source model. It can be used to filter the layers list in a widget.

The QgsMapLayerProxyModel class provides an easy to use model to display the list of layers in widgets.

New in version 2.3.

Parameters

parent

All = 63
class Filter

Bases: int

class Filters

Bases: sip.wrapper

QgsMapLayerProxyModel.Filters(Union[QgsMapLayerProxyModel.Filters, QgsMapLayerProxyModel.Filter]) QgsMapLayerProxyModel.Filters(QgsMapLayerProxyModel.Filters)

baseClass

alias of QgsMapLayerProxyModel

HasGeometry = 28
LineLayer = 8
NoGeometry = 2
PluginLayer = 32
PointLayer = 4
PolygonLayer = 16
RasterLayer = 1
VectorLayer = 30
WritableLayer = 64
beginInsertColumns()
beginInsertRows()
beginMoveColumns()
beginMoveRows()
beginRemoveColumns()
beginRemoveRows()
beginResetModel()
changePersistentIndex()
changePersistentIndexList()
childEvent()
connectNotify()
createIndex()
customEvent()
decodeData()
disconnectNotify()
encodeData()
endInsertColumns()
endInsertRows()
endMoveColumns()
endMoveRows()
endRemoveColumns()
endRemoveRows()
endResetModel()
exceptedLayerIds(self) → List[str]

Returns the blacklist of layer IDs which are excluded from the model.

Return type

List[str]

exceptedLayerList(self) → List[QgsMapLayer]

Returns the blacklist of layers which are excluded from the model.

See also

layerWhitelist()

Return type

List[QgsMapLayer]

excludedProviders(self) → List[str]

Returns the blacklist of data providers which are excluded from the model.

New in version 3.0.

Return type

List[str]

filterAcceptsColumn()
filterAcceptsRow(self, source_row: int, source_parent: QModelIndex) → bool
Parameters
  • source_row (int) –

  • source_parent (QModelIndex) –

Return type

bool

filterString(self) → str

Returns the current filter string, if set.

New in version 3.4.

Return type

str

filters(self) → QgsMapLayerProxyModel.Filters

Returns the filter flags which affect how layers are filtered within the model.

See also

setFilters()

New in version 2.3.

Return type

QgsMapLayerProxyModel.Filters

invalidateFilter()
isSignalConnected()
layerWhitelist(self) → List[QgsMapLayer]

Returns the list of layers which are excluded from the model.

An empty list indicates that no whitelisting should be performed.

New in version 3.4.

Return type

List[QgsMapLayer]

lessThan(self, left: QModelIndex, right: QModelIndex) → bool
Parameters
  • left (QModelIndex) –

  • right (QModelIndex) –

Return type

bool

persistentIndexList()
receivers()
resetInternalData()
sender()
senderSignalIndex()
setExceptedLayerIds(self, ids: Iterable[str])

Sets a blacklist of layers (by layer ID) to exclude from the model.

Parameters

ids (Iterable[str]) –

setExceptedLayerList(self, exceptList: Iterable[QgsMapLayer])

Sets a blacklist of layers to exclude from the model.

Parameters

exceptList (Iterable[QgsMapLayer]) –

setExcludedProviders(self, providers: Iterable[str])

Sets a blacklist of data providers which should be excluded from the model.

New in version 3.0.

Parameters

providers (Iterable[str]) –

setFilterString(self, filter: str)

Sets a filter string, such that only layers with names matching the specified string will be shown.

See also

filterString()

New in version 3.4.

Parameters

filter (str) –

setFilters(self, filters: Union[QgsMapLayerProxyModel.Filters, QgsMapLayerProxyModel.Filter]) → QgsMapLayerProxyModel

Sets filter flags which affect how layers are filtered within the model.

See also

filters()

New in version 2.3.

Parameters

filters (Union[QgsMapLayerProxyModel.Filters) –

Return type

QgsMapLayerProxyModel

setLayerWhitelist(self, layers: Iterable[QgsMapLayer])

Sets a whitelist of layers to include within the model. Only layers from this list will be shown.

An empty list indicates that no whitelisting should be performed.

See also

layerWhitelist()

New in version 3.4.

Parameters

layers (Iterable[QgsMapLayer]) –

sourceLayerModel(self) → QgsMapLayerModel

layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel

Return type

QgsMapLayerModel

timerEvent()