Class: QgsPluginLayer

class qgis.core.QgsPluginLayer

Bases: QgsMapLayer

Base class for plugin layers. These can be implemented by plugins and registered in QgsPluginLayerRegistry.

In order to be readable from project files, they should set these attributes in layer DOM node: “type” = “plugin” “name” = “your_layer_type”

Methods

appendError

Add error message

childEvent

clone

Returns a new instance equivalent to this one.

connectNotify

customEvent

dataProvider

rtype

QgsDataProvider

decodedSource

Called by readLayerXML(), used by derived classes to decode provider’s specific data source from project files.

disconnectNotify

encodedSource

Called by writeLayerXML(), used by derived classes to encode provider’s specific data source to project files.

hasDependencyCycle

Checks whether a new set of dependencies will introduce a cycle this method is now deprecated and always return false, because circular dependencies are now correctly managed.

isSignalConnected

pluginLayerType

Returns plugin layer type (the same as used in QgsPluginLayerRegistry)

readCommonStyle

Read style data common to all layer types

readCustomProperties

Read custom properties from project file.

readStyleManager

Read style manager’s configuration (if any).

readXml

Called by readLayerXML(), used by children to read state specific to them from project files.

receivers

sender

senderSignalIndex

setError

Sets error message

setExtent

Sets extent of the layer

setProviderType

Sets the providerType (provider key)

setSource

Set source string.

setValid

Sets whether layer is valid or not

timerEvent

writeCommonStyle

Write style data common to all layer types

writeCustomProperties

Write custom properties to project file.

writeStyleManager

Write style manager’s configuration (if exists).

writeXml

Called by writeLayerXML(), used by children to write state specific to them to project files.

appendError(self, error: QgsErrorMessage)

Add error message

childEvent(self, QChildEvent)
clone(self)QgsPluginLayer

Returns a new instance equivalent to this one.

Return type

QgsPluginLayer

Returns

a new layer instance

New in version 3.0.

connectNotify(self, QMetaMethod)
customEvent(self, QEvent)
dataProvider(self)QgsDataProvider
Return type

QgsDataProvider

decodedSource(self, source: str, dataProvider: str, context: QgsReadWriteContext) → str

Called by readLayerXML(), used by derived classes to decode provider’s specific data source from project files. Typically resolving absolute or relative paths, usernames and passwords or drivers prefixes (“HDF5:”)

Parameters
  • source – data source to decode, typically read from layer’s DOM element “datasource”

  • dataProvider – string identification of data provider (e.g. “ogr”), typically read from layer’s DOM element

  • context – reading context (e.g. for conversion between relative and absolute paths)

Returns

decoded source, typically to be used as the layer’s datasource

New in version 3.2.

disconnectNotify(self, QMetaMethod)
encodedSource(self, source: str, context: QgsReadWriteContext) → str

Called by writeLayerXML(), used by derived classes to encode provider’s specific data source to project files. Typically resolving absolute or relative paths, usernames and passwords or drivers prefixes (“HDF5:”)

Parameters
  • source – data source to encode, typically QgsMapLayer.source()

  • context – writing context (e.g. for conversion between relative and absolute paths)

Returns

encoded source, typically to be written in the DOM element “datasource”

New in version 3.2.

hasDependencyCycle(self, Iterable[QgsMapLayerDependency]) → bool

Checks whether a new set of dependencies will introduce a cycle this method is now deprecated and always return false, because circular dependencies are now correctly managed.

Deprecated since version QGIS: 3.10

isSignalConnected(self, QMetaMethod) → bool
pluginLayerType(self) → str

Returns plugin layer type (the same as used in QgsPluginLayerRegistry)

Return type

str

readCommonStyle(self, layerElement: QDomElement, context: QgsReadWriteContext, categories: Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories)

Read style data common to all layer types

New in version 3.0.

readCustomProperties(self, layerNode: QDomNode, keyStartsWith: str = '')

Read custom properties from project file.

Parameters
  • layerNode – note to read from

  • keyStartsWith – reads only properties starting with the specified string (or all if the string is empty)

readStyleManager(self, layerNode: QDomNode)

Read style manager’s configuration (if any). To be called by subclasses.

readXml(self, layer_node: QDomNode, context: QgsReadWriteContext) → bool

Called by readLayerXML(), used by children to read state specific to them from project files.

receivers(self, PYQT_SIGNAL) → int
sender(self) → QObject
senderSignalIndex(self) → int
setError(self, error: QgsError)

Sets error message

setExtent(self, extent: QgsRectangle)

Sets extent of the layer

Parameters

extent (QgsRectangle) –

setProviderType(self, providerType: str)

Sets the providerType (provider key)

setSource(self, source: str)

Set source string. This is used for example in layer tree to show tooltip.

New in version 2.16.

Parameters

source (str) –

setValid(self, valid: bool)

Sets whether layer is valid or not

timerEvent(self, QTimerEvent)
writeCommonStyle(self, layerElement: QDomElement, document: QDomDocument, context: QgsReadWriteContext, categories: Union[QgsMapLayer.StyleCategories, QgsMapLayer.StyleCategory] = QgsMapLayer.AllStyleCategories)

Write style data common to all layer types

New in version 3.0.

writeCustomProperties(self, layerNode: QDomNode, doc: QDomDocument)

Write custom properties to project file.

writeStyleManager(self, layerNode: QDomNode, doc: QDomDocument)

Write style manager’s configuration (if exists). To be called by subclasses.

writeXml(self, layer_node: QDomNode, document: QDomDocument, context: QgsReadWriteContext) → bool

Called by writeLayerXML(), used by children to write state specific to them to project files.