Class: QgsMimeDataUtils

class qgis.core.QgsMimeDataUtils
class qgis.core.QgsMimeDataUtils(a0: QgsMimeDataUtils)

Bases: sip.wrapper

Methods

decodeUriList

param data:

encodeUriList

Encodes a URI list to a new QMimeData object.

hasOriginatedFromCurrentAppInstance

Returns True if uri originated from the current QGIS application instance.

isUriList

param data:

layerTreeNodesToUriList

Returns encoded URI list from a list of layer tree nodes.

class Uri

Bases: sip.wrapper

Constructs invalid URI

QgsMimeDataUtils.Uri(encData: Optional[str]) Constructs URI from encoded data

QgsMimeDataUtils.Uri(layer: Optional[QgsMapLayer]) Constructs a URI corresponding to the specified layer.

Added in version 3.8.

QgsMimeDataUtils.Uri(a0: QgsMimeDataUtils.Uri)

data(self) str

Returns encoded representation of the object

Return type:

str

filePath
isValid(self) bool

Returns whether the object contains valid data

Return type:

bool

layerId
layerType
mapLayer(self) QgsMapLayer | None

Returns the layer from the active project corresponding to this uri (if possible), otherwise returns None.

Unlike vectorLayer(), rasterLayer(), or meshLayer(), this method will not attempt to create a new layer corresponding to the URI.

Added in version 3.8.

Return type:

Optional[QgsMapLayer]

meshLayer(self, error: str | None)

Gets mesh layer from uri if possible, otherwise returns None and error is set

Parameters:
  • owner – set to True if caller becomes owner

  • error (Optional[str]) -> (Optional[QgsMeshLayer]) – set to error message if cannot get raster

name
pId
providerKey
rasterLayer(self, error: str | None)

Gets raster layer from uri if possible, otherwise returns None and error is set

Parameters:
  • owner – set to True if caller becomes owner

  • error (Optional[str]) -> (Optional[QgsRasterLayer]) – set to error message if cannot get raster

supportedCrs
supportedFormats
uri
vectorLayer(self, error: str | None)

Gets vector layer from uri if possible, otherwise returns None and error is set

Parameters:
  • owner – set to True if caller becomes owner

  • error (Optional[str]) -> (Optional[QgsVectorLayer]) – set to error message if cannot get vector

wkbType
decodeUriList(data: QMimeData | None) List[QgsMimeDataUtils.Uri]
Parameters:

data (Optional[QMimeData])

Return type:

List[QgsMimeDataUtils.Uri]

encodeUriList(layers: Iterable[QgsMimeDataUtils.Uri]) QMimeData | None

Encodes a URI list to a new QMimeData object.

Parameters:

layers (Iterable[QgsMimeDataUtils.Uri])

Return type:

Optional[QMimeData]

hasOriginatedFromCurrentAppInstance(uri: QgsMimeDataUtils.Uri) bool

Returns True if uri originated from the current QGIS application instance.

Added in version 3.8.

Parameters:

uri (QgsMimeDataUtils.Uri)

Return type:

bool

isUriList(data: QMimeData | None) bool
Parameters:

data (Optional[QMimeData])

Return type:

bool

layerTreeNodesToUriList(nodes: Iterable[QgsLayerTreeNode]) QByteArray

Returns encoded URI list from a list of layer tree nodes.

Parameters:

nodes (Iterable[QgsLayerTreeNode])

Return type:

QByteArray