Class: QgsMapLayerProxyModel

class qgis.core.QgsMapLayerProxyModel

Bases: PyQt5.QtCore.QSortFilterProxyModel

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

New in version 2.3.

QgsMapLayerProxyModel(parent: QObject = None) QgsMapLayerProxModel creates a proxy model with a QgsMapLayerModel as source model. It can be used to filter the layers list in a widget.

Methods

acceptsLayer

Returns True if the proxy model accepts the specified map layer.

beginInsertColumns

beginInsertRows

beginMoveColumns

beginMoveRows

beginRemoveColumns

beginRemoveRows

beginResetModel

changePersistentIndex

changePersistentIndexList

childEvent

connectNotify

createIndex

customEvent

decodeData

disconnectNotify

encodeData

endInsertColumns

endInsertRows

endMoveColumns

endMoveRows

endRemoveColumns

endRemoveRows

endResetModel

exceptedLayerIds

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

exceptedLayerList

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

excludedProviders

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

filterAcceptsColumn

filterAcceptsRow

param source_row

filterString

Returns the current filter string, if set.

filters

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

invalidateFilter

isSignalConnected

layerAllowlist

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

layerMatchesFilters

Returns if the layer matches the given filters

layerWhitelist

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

lessThan

param left

persistentIndexList

receivers

resetInternalData

sender

senderSignalIndex

setExceptedLayerIds

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

setExceptedLayerList

Sets a blocklist of layers to exclude from the model.

setExcludedProviders

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

setFilterString

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

setFilters

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

setLayerAllowlist

Sets an allowlist of layers to include within the model.

setLayerWhitelist

Sets an allowlist of layers to include within the model.

sourceLayerModel

layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel

timerEvent

Attributes

All

HasGeometry

LineLayer

MeshLayer

NoGeometry

PluginLayer

PointCloudLayer

PointLayer

PolygonLayer

RasterLayer

VectorLayer

VectorTileLayer

WritableLayer

All = 959
class Filter

Bases: int

class Filters

Bases: sip.wrapper

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

baseClass

alias of qgis._core.QgsMapLayerProxyModel

HasGeometry = 28
LineLayer = 8
MeshLayer = 128
NoGeometry = 2
PluginLayer = 32
PointCloudLayer = 512
PointLayer = 4
PolygonLayer = 16
RasterLayer = 1
VectorLayer = 30
VectorTileLayer = 256
WritableLayer = 64
acceptsLayer(self, layer: QgsMapLayer)bool

Returns True if the proxy model accepts the specified map layer.

New in version 3.8.

Parameters

layer (QgsMapLayer) –

Return type

bool

QgsMapLayerProxyModel.beginInsertColumns(self, QModelIndex, int, int)
QgsMapLayerProxyModel.beginInsertRows(self, QModelIndex, int, int)
QgsMapLayerProxyModel.beginMoveColumns(self, QModelIndex, int, int, QModelIndex, int) -> bool
QgsMapLayerProxyModel.beginMoveRows(self, QModelIndex, int, int, QModelIndex, int) -> bool
QgsMapLayerProxyModel.beginRemoveColumns(self, QModelIndex, int, int)
QgsMapLayerProxyModel.beginRemoveRows(self, QModelIndex, int, int)
beginResetModel(self)
QgsMapLayerProxyModel.changePersistentIndex(self, QModelIndex, QModelIndex)
changePersistentIndexList(self, Iterable[QModelIndex], Iterable[QModelIndex])
childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
QgsMapLayerProxyModel.createIndex(self, int, int, object: object = 0) -> QModelIndex
customEvent(self, QEvent)
QgsMapLayerProxyModel.decodeData(self, int, int, QModelIndex, QDataStream) -> bool
disconnectNotify(self, QMetaMethod)
encodeData(self, Iterable[QModelIndex], QDataStream)
endInsertColumns(self)
endInsertRows(self)
endMoveColumns(self)
endMoveRows(self)
endRemoveColumns(self)
endRemoveRows(self)
endResetModel(self)
exceptedLayerIds(self)List[str]

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

Return type

List[str]

exceptedLayerList(self)List[QgsMapLayer]

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

See also

layerAllowlist()

Return type

List[QgsMapLayer]

excludedProviders(self)List[str]

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

New in version 3.0.

Return type

List[str]

filterAcceptsColumn(self, int, QModelIndex)bool
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(self)
isSignalConnected(self, QMetaMethod)bool
layerAllowlist(self)List[QgsMapLayer]

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

An empty list indicates that no filtering by allowlist should be performed.

New in version 3.14.

Return type

List[QgsMapLayer]

layerMatchesFilters(layer: QgsMapLayer, filters: Union[QgsMapLayerProxyModel.Filters, QgsMapLayerProxyModel.Filter])bool

Returns if the layer matches the given filters

New in version 3.14.

Parameters
Return type

bool

layerWhitelist(self)List[QgsMapLayer]

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

An empty list indicates that no filtering by allowlist should be performed.

Deprecated since version use: layerAllowlist() instead

Return type

List[QgsMapLayer]

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

  • right (QModelIndex) –

Return type

bool

persistentIndexList(self)List[QModelIndex]
receivers(self, PYQT_SIGNAL)int
resetInternalData(self)
sender(self)QObject
senderSignalIndex(self)int
setExceptedLayerIds(self, ids: Iterable[str])

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

Parameters

ids (Iterable[str]) –

setExceptedLayerList(self, exceptList: Iterable[QgsMapLayer])

Sets a blocklist of layers to exclude from the model.

Parameters

exceptList (Iterable[QgsMapLayer]) –

setExcludedProviders(self, providers: Iterable[str])

Sets a blocklist 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

setLayerAllowlist(self, layers: Iterable[QgsMapLayer])

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

An empty list indicates that no filter by allowlist should be performed.

See also

layerAllowlist()

New in version 3.14.

Parameters

layers (Iterable[QgsMapLayer]) –

setLayerWhitelist(self, layers: Iterable[QgsMapLayer])

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

An empty list indicates that no filter by allowlist should be performed.

See also

layerAllowlist()

Deprecated since version use: setLayerAllowList()

Parameters

layers (Iterable[QgsMapLayer]) –

sourceLayerModel(self)QgsMapLayerModel

layerModel returns the QgsMapLayerModel used in this QSortFilterProxyModel

Return type

QgsMapLayerModel

timerEvent(self, QTimerEvent)