Class: QgsMimeDataUtils¶
Contains utility functions for working with MIME data.
List of all members, including inherited members
Classes
Constructs invalid URI |
Static Methods
Encodes a URI list to a new QMimeData object. |
|
Returns |
|
Returns encoded URI list from a list of layer tree nodes. |
- class qgis.core.QgsMimeDataUtils[source]¶
Bases:
object- class Uri¶
Bases:
objectConstructs invalid URI
- __init__(encData: str | None)
Constructs URI from encoded data
- Parameters:
encData (Optional[str])
- __init__(layer: QgsMapLayer | None)
Constructs a URI corresponding to the specified
layer.Added in version 3.8.
- Parameters:
layer (Optional[QgsMapLayer])
- __init__(a0: QgsMimeDataUtils.Uri)
- Parameters:
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]) – set to error message if cannot get raster
- Return type:
(Optional[QgsMeshLayer], bool)
- 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]) – set to error message if cannot get raster
- Return type:
(Optional[QgsRasterLayer], bool)
- 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]) – set to error message if cannot get vector
- Return type:
(Optional[QgsVectorLayer], bool)
- 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
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