Class: QgsLayerItem

A browser item that represents a layer that can be opened with one of the providers.

Class Hierarchy

Inheritance diagram of qgis.core.QgsLayerItem

Base classes

QgsDataItem

Base class for all items in the model.

QObject

class qgis.core.QgsLayerItem[source]

Bases: QgsDataItem

__init__(parent: QgsDataItem | None, name: str | None, path: str | None, uri: str | None, layerType: Qgis.BrowserLayerType, providerKey: str | None)

Constructor for QgsLayerItem.

Parameters:
LayerType

alias of BrowserLayerType

virtual comments(self) str[source]

Returns comments of the layer

Return type:

str

virtual deleteLayer(self) bool[source]

Delete this layer item Use QgsDataItemGuiProvider.deleteLayer instead

Deprecated since version 3.10.

Return type:

bool

static iconDefault() QIcon[source]
Return type:

QIcon

static iconForWkbType(type: Qgis.WkbType) QIcon[source]

Returns the icon for a vector layer whose geometry type is provided.

Added in version 3.18.

Parameters:

type (Qgis.WkbType)

Return type:

QIcon

static iconLine() QIcon[source]
Return type:

QIcon

static iconMesh() QIcon[source]

Returns icon for mesh layer type

Return type:

QIcon

static iconName(layerType: Qgis.BrowserLayerType) str[source]

Returns the icon name of the given layerType

Added in version 3.

Parameters:

layerType (Qgis.BrowserLayerType)

Return type:

str

static iconPoint() QIcon[source]
Return type:

QIcon

static iconPointCloud() QIcon[source]

Returns icon for point cloud layer

Return type:

QIcon

static iconPolygon() QIcon[source]
Return type:

QIcon

static iconRaster() QIcon[source]
Return type:

QIcon

static iconTable() QIcon[source]
Return type:

QIcon

static iconVectorTile() QIcon[source]

Returns icon for vector tile layer

Return type:

QIcon

layerMetadata(self) QgsLayerMetadata

Returns layer’s metadata, it may be a default constructed metadata if metadata is not explicitly set.

Added in version 3.28.

Return type:

QgsLayerMetadata

virtual layerName(self) str[source]

Returns the layer name

Return type:

str

static layerTypeAsString(layerType: Qgis.BrowserLayerType) str[source]

Returns the string representation of the given layerType

Added in version 3.

Parameters:

layerType (Qgis.BrowserLayerType)

Return type:

str

mapLayerType(self) Qgis.LayerType[source]

Returns the associated map layer type.

Return type:

Qgis.LayerType

setLayerMetadata(self, metadata: QgsLayerMetadata)[source]

Set layer’s metadata.

Added in version 3.28.

Parameters:

metadata (QgsLayerMetadata)

supportedCrs(self) List[str][source]

Returns the supported CRS

Return type:

List[str]

supportedFormats(self) List[str][source]

Returns the supported formats

Return type:

List[str]

static typeFromMapLayer(layer: QgsMapLayer | None) Qgis.BrowserLayerType[source]

Returns the layer item type corresponding to a QgsMapLayer layer.

Added in version 3.6.

Parameters:

layer (Optional[QgsMapLayer])

Return type:

Qgis.BrowserLayerType

uri(self) str[source]

Returns layer uri or empty string if layer cannot be created

Return type:

str