Class: QgsLayerItem

class qgis.core.QgsLayerItem

Bases: QgsDataItem

Item that represents a layer that can be opened with one of the providers

Methods

childEvent

comments

Returns comments of the layer

connectNotify

customEvent

deferredDelete

The item is scheduled to be deleted.

deleteLayer

Delete this layer item Use QgsDataItemGuiProvider.deleteLayer instead

disconnectNotify

equal

param other

hasDragEnabled

rtype

bool

iconDefault

rtype

QIcon

iconLine

rtype

QIcon

iconMesh

Returns icon for mesh layer type

iconName

Returns the icon name of the given layerType

iconPoint

rtype

QIcon

iconPointCloudLayer

Returns icon for point cloud layer

iconPolygon

rtype

QIcon

iconRaster

rtype

QIcon

iconTable

rtype

QIcon

iconVectorTile

Returns icon for vector tile layer

isSignalConnected

layerName

rtype

str

layerTypeAsString

Returns the string representation of the given layerType

mapLayerType

Returns QgsMapLayerType

mimeUri

rtype

QgsMimeDataUtils.Uri

populate

populate(self, foreground: bool = False)

providerKey

Returns provider key

receivers

refresh

Refresh the items from a specified list of child items.

sender

senderSignalIndex

supportedCrs

Returns the supported CRS

supportedFormats

Returns the supported formats

timerEvent

typeFromMapLayer

Returns the layer item type corresponding to a QgsMapLayer layer.

updateIcon

Will request a repaint of this icon.

uri

Returns layer uri or empty string if layer cannot be created

Attributes

Database

Line

Mesh

NoType

Plugin

Point

PointCloud

Polygon

Raster

Table

TableLayer

Vector

VectorTile

Database = 7
class LayerType

Bases: int

baseClass

alias of QgsLayerItem

Line = 4
Mesh = 10
NoType = 0
Plugin = 9
Point = 3
PointCloud = 12
Polygon = 5
Raster = 2
Table = 8
TableLayer = 6
Vector = 1
VectorTile = 11
childEvent(self, QChildEvent)
comments(self) → str

Returns comments of the layer

New in version 2.12.

Return type

str

connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
deferredDelete(self) → bool

The item is scheduled to be deleted. E.g. if deleteLater() is called when item is in Populating state (createChildren() running in another thread), the deferredDelete() returns True and item will be deleted once Populating finished. Items with slow reateChildren() (for example network or database based) may check during createChildren() if deferredDelete() returns True and return from createChildren() immediately because result will be useless.

deleteLayer(self) → bool

Delete this layer item Use QgsDataItemGuiProvider.deleteLayer instead

Deprecated since version QGIS: 3.10

Return type

bool

disconnectNotify(self, QMetaMethod)
equal(self, other: QgsDataItem) → bool
Parameters

other (QgsDataItem) –

Return type

bool

hasDragEnabled(self) → bool
Return type

bool

iconDefault() → QIcon
Return type

QIcon

iconLine() → QIcon
Return type

QIcon

iconMesh() → QIcon

Returns icon for mesh layer type

Return type

QIcon

iconName(layerType: QgsLayerItem.LayerType) → str

Returns the icon name of the given layerType

New in version 3.

Parameters

layerType (QgsLayerItem.LayerType) –

Return type

str

iconPoint() → QIcon
Return type

QIcon

iconPointCloudLayer() → QIcon

Returns icon for point cloud layer

Return type

QIcon

iconPolygon() → QIcon
Return type

QIcon

iconRaster() → QIcon
Return type

QIcon

iconTable() → QIcon
Return type

QIcon

iconVectorTile() → QIcon

Returns icon for vector tile layer

Return type

QIcon

isSignalConnected(self, QMetaMethod) → bool
layerName(self) → str
Return type

str

Returns

the layer name

layerTypeAsString(layerType: QgsLayerItem.LayerType) → str

Returns the string representation of the given layerType

New in version 3.

Parameters

layerType (QgsLayerItem.LayerType) –

Return type

str

mapLayerType(self)QgsMapLayerType

Returns QgsMapLayerType

Return type

QgsMapLayerType

mimeUri(self)QgsMimeDataUtils.Uri
Return type

QgsMimeDataUtils.Uri

populate(self, children: object)

populate(self, foreground: bool = False)

providerKey(self) → str

Returns provider key

Return type

str

receivers(self, PYQT_SIGNAL) → int
refresh(self, children: object)

Refresh the items from a specified list of child items.

refresh(self)

sender(self) → QObject
senderSignalIndex(self) → int
supportedCrs(self) → List[str]

Returns the supported CRS

New in version 2.8.

Return type

List[str]

supportedFormats(self) → List[str]

Returns the supported formats

New in version 2.8.

Return type

List[str]

timerEvent(self, QTimerEvent)
typeFromMapLayer(layer: QgsMapLayer)QgsLayerItem.LayerType

Returns the layer item type corresponding to a QgsMapLayer layer.

New in version 3.6.

Parameters

layer (QgsMapLayer) –

Return type

QgsLayerItem.LayerType

updateIcon(self)

Will request a repaint of this icon.

New in version 3.0.

uri(self) → str

Returns layer uri or empty string if layer cannot be created

Return type

str