Class: QgsMapLayerProxyModel¶
A proxy model which provides an easy to use model to display the list of layers in widgets.
Class Hierarchy¶
Base classes¶
Enums
alias of |
Methods
Returns |
|
Returns the blocklist of layer IDs which are excluded from the model. |
|
Returns the blocklist of layers which are excluded from the model. |
|
Returns the blocklist of data providers which are excluded from the model. |
|
Returns the current filter string, if set. |
|
Returns the filter flags which affect how layers are filtered within the model. |
|
Returns the list of layers which are excluded from the model. |
|
Returns the list of layers which are excluded from the model. |
|
Sets a blocklist of layers (by layer ID) to exclude from the model. |
|
Sets a blocklist of layers to exclude from the model. |
|
Sets a blocklist of data providers which should be excluded from the model. |
|
Sets a filter string, such that only layers with names matching the specified string will be shown. |
|
Sets filter flags which affect how layers are filtered within the model. |
|
Sets an allowlist of layers to include within the model. |
|
Sets an allowlist of layers to include within the model. |
|
Sets the project from which map layers are shown. |
|
layerModel returns the |
Static Methods
Returns if the layer matches the given filters |
- class qgis.core.QgsMapLayerProxyModel[source]¶
Bases:
QSortFilterProxyModel
- __init__(parent: QObject | None = None)
QgsMapLayerProxModel
creates a proxy model with aQgsMapLayerModel
as source model. It can be used to filter the layers list in a widget.- Parameters:
parent (Optional[QObject] = None)
- Filter¶
alias of
LayerFilter
- acceptsLayer(self, layer: QgsMapLayer | None) bool [source]¶
Returns
True
if the proxy model accepts the specified maplayer
.Added in version 3.8.
- Parameters:
layer (Optional[QgsMapLayer])
- Return type:
bool
- exceptedLayerIds(self) List[str] [source]¶
Returns the blocklist of layer IDs which are excluded from the model.
See also
See also
- Return type:
List[str]
- exceptedLayerList(self) List[QgsMapLayer] ¶
Returns the blocklist of layers which are excluded from the model.
See also
See also
See also
- Return type:
List[QgsMapLayer]
- excludedProviders(self) List[str] [source]¶
Returns the blocklist of data providers which are excluded from the model.
See also
- Return type:
List[str]
- filterString(self) str [source]¶
Returns the current filter string, if set.
See also
Added in version 3.4.
- Return type:
str
- filters(self) Qgis.LayerFilters ¶
Returns the filter flags which affect how layers are filtered within the model.
See also
- Return type:
- 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.
See also
See also
Added in version 3.14.
- Return type:
List[QgsMapLayer]
- static layerMatchesFilters(layer: QgsMapLayer | None, filters: Qgis.LayerFilters | Qgis.LayerFilter) bool [source]¶
Returns if the
layer
matches the givenfilters
Added in version 3.14.
- Parameters:
layer (Optional[QgsMapLayer])
filters (Union[Qgis.LayerFilters, Qgis.LayerFilter])
- 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.
See also
See also
Deprecated since version 3.40: Use
layerAllowlist()
instead.- Return type:
List[QgsMapLayer]
- setExceptedLayerIds(self, ids: Iterable[str | None])[source]¶
Sets a blocklist of layers (by layer ID) to exclude from the model.
See also
See also
- Parameters:
ids (Iterable[Optional[str]])
- setExceptedLayerList(self, exceptList: Iterable[QgsMapLayer])[source]¶
Sets a blocklist of layers to exclude from the model.
See also
See also
See also
- Parameters:
exceptList (Iterable[QgsMapLayer])
- setExcludedProviders(self, providers: Iterable[str | None])[source]¶
Sets a blocklist of data providers which should be excluded from the model.
See also
- Parameters:
providers (Iterable[Optional[str]])
- setFilterString(self, filter: str | None)[source]¶
Sets a
filter
string, such that only layers with names matching the specified string will be shown.See also
Added in version 3.4.
- Parameters:
filter (Optional[str])
- setFilters(self, filters: Qgis.LayerFilters | Qgis.LayerFilter) QgsMapLayerProxyModel | None [source]¶
Sets
filter
flags which affect how layers are filtered within the model.See also
- Parameters:
filters (Union[Qgis.LayerFilters, Qgis.LayerFilter])
- Return type:
Optional[QgsMapLayerProxyModel]
- setFilters(self, filters: int)[source]
Filters according to layer type and/or geometry type.
Note
for API compatibility
Added in version 3.34.
Deprecated since version 3.34: Use the flag signature instead.
- Parameters:
filters (int)
- setLayerAllowlist(self, layers: Iterable[QgsMapLayer])[source]¶
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
See also
Added in version 3.14.
- Parameters:
layers (Iterable[QgsMapLayer])
- setLayerWhitelist(self, layers: Iterable[QgsMapLayer])[source]¶
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
See also
Deprecated since version 3.40: Use
setLayerAllowList()
.- Parameters:
layers (Iterable[QgsMapLayer])
- setProject(self, project: QgsProject | None)[source]¶
Sets the
project
from which map layers are shown.If
project
isNone
thenQgsProject.instance()
will be used.Added in version 3.24.
- Parameters:
project (Optional[QgsProject])
- sourceLayerModel(self) QgsMapLayerModel | None [source]¶
layerModel returns the
QgsMapLayerModel
used in this QSortFilterProxyModel- Return type:
Optional[QgsMapLayerModel]