Class: QgsMimeDataUtils

Contains utility functions for working with MIME data.

class qgis.core.QgsMimeDataUtils[source]

Bases: object

class Uri

Bases: object

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: str
isValid(self) bool

Returns whether the object contains valid data

Return type:

bool

layerId: str
layerType: str
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: str
pId: str
providerKey: str
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: str
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: WkbType
static decodeUriList(data: QMimeData | None) List[QgsMimeDataUtils.Uri][source]
Parameters:

data (Optional[QMimeData])

Return type:

List[QgsMimeDataUtils.Uri]

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

Encodes a URI list to a new QMimeData object.

Parameters:

layers (Iterable[QgsMimeDataUtils.Uri])

Return type:

Optional[QMimeData]

static hasOriginatedFromCurrentAppInstance(uri: QgsMimeDataUtils.Uri) bool[source]

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

Added in version 3.8.

Parameters:

uri (QgsMimeDataUtils.Uri)

Return type:

bool

static isUriList(data: QMimeData | None) bool[source]
Parameters:

data (Optional[QMimeData])

Return type:

bool

static layerTreeNodesToUriList(nodes: Iterable[QgsLayerTreeNode]) QByteArray[source]

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

Parameters:

nodes (Iterable[QgsLayerTreeNode])

Return type:

QByteArray