Class: QgsMimeDataUtils¶
Contains utility functions for working with MIME data.
- class qgis.core.QgsMimeDataUtils[source]¶
Bases:
object- class Uri¶
Bases:
objectConstructs 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(), ormeshLayer(), 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
Noneand error is set- Parameters:
owner – set to
Trueif caller becomes ownererror (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
Noneand error is set- Parameters:
owner – set to
Trueif caller becomes ownererror (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
Noneand error is set- Parameters:
owner – set to
Trueif caller becomes ownererror (Optional[str]) -> (Optional[QgsVectorLayer]) – set to error message if cannot get vector
- static decodeUriList(data: QMimeData | None) List[QgsMimeDataUtils.Uri][source]¶
- Parameters:
data (Optional[QMimeData])
- Return type:
- 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
Trueifurioriginated 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