Class: QgsMetadataWidget

A wizard to edit metadata on a map layer.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsMetadataWidget

Base classes

QWidget

QObject

QPaintDevice

Methods

acceptMetadata

Saves the metadata to the layer.

checkMetadata

Check if values in the wizard are correct.

crsChanged

If the CRS is updated.

metadata

Returns a QgsAbstractMetadataBase object representing the current state of the widget.

mode

Returns the widget's current mode.

saveMetadata

Save all fields in a metadata object.

setMapCanvas

Sets a map canvas associated with the widget.

setMetadata

Sets the metadata to display in the widget.

setMode

Sets the widget's current mode.

setTitle

Sets the title field for the metadata.

title

Returns the current title field for the metadata.

Static Methods

parseLanguages

Returns a list of languages available by default in the wizard.

parseLicenses

Returns a list of licences available by default in the wizard.

parseLinkTypes

Returns a list of link types available by default in the wizard.

parseMimeTypes

Returns a list of MIME types available by default in the wizard.

parseTypes

Returns a list of types available by default in the wizard.

Signals

titleChanged

Emitted when the title field is changed.

Attributes

LayerMetadata

ProjectMetadata

class qgis.gui.QgsMetadataWidget[source]

Bases: QWidget

__init__(parent: QWidget | None = None, layer: QgsMapLayer | None = None)

Constructor for the wizard.

If layer is set, then this constructor automatically sets the widget’s metadata() to match the layer’s metadata..

See also

setMetadata()

Parameters:
  • parent (Optional[QWidget] = None)

  • layer (Optional[QgsMapLayer] = None)

LayerMetadata = 0
class Mode

Bases: int

ProjectMetadata = 1
acceptMetadata(self)[source]

Saves the metadata to the layer.

checkMetadata(self) bool[source]

Check if values in the wizard are correct.

See also

saveMetadata()

Return type:

bool

crsChanged(self)[source]

If the CRS is updated.

metadata(self) QgsAbstractMetadataBase | None[source]

Returns a QgsAbstractMetadataBase object representing the current state of the widget.

Caller takes ownership of the returned object.

See also

saveMetadata()

Return type:

Optional[QgsAbstractMetadataBase]

mode(self) QgsMetadataWidget.Mode[source]

Returns the widget’s current mode.

See also

setMode()

Added in version 3.2.

Return type:

QgsMetadataWidget.Mode

static parseLanguages() Dict[str, str]

Returns a list of languages available by default in the wizard.

Return type:

Dict[str, str]

static parseLicenses() List[str][source]

Returns a list of licences available by default in the wizard.

Return type:

List[str]

static parseLinkTypes() List[str][source]

Returns a list of link types available by default in the wizard.

Return type:

List[str]

static parseMimeTypes() List[str][source]

Returns a list of MIME types available by default in the wizard.

Return type:

List[str]

static parseTypes() Dict[str, str]

Returns a list of types available by default in the wizard.

Return type:

Dict[str, str]

saveMetadata(self, metadata: QgsAbstractMetadataBase | None)[source]

Save all fields in a metadata object.

See also

metadata()

See also

acceptMetadata()

See also

checkMetadata()

Parameters:

metadata (Optional[QgsAbstractMetadataBase])

setMapCanvas(self, canvas: QgsMapCanvas | None)[source]

Sets a map canvas associated with the widget.

Parameters:

canvas (Optional[QgsMapCanvas])

setMetadata(self, metadata: QgsAbstractMetadataBase | None)[source]

Sets the metadata to display in the widget.

This method can be called after constructing a QgsMetadataWidget in order to set the displayed metadata to custom, non-layer based metadata.

Calling this method will automatically setMode() to the correct mode corresponding to the specified metadata object.

See also

metadata()

Parameters:

metadata (Optional[QgsAbstractMetadataBase])

setMode(self, mode: QgsMetadataWidget.Mode)[source]

Sets the widget’s current mode.

See also

mode()

Added in version 3.2.

Parameters:

mode (QgsMetadataWidget.Mode)

setTitle(self, title: str | None)[source]

Sets the title field for the metadata.

See also

title()

See also

titleChanged()

Added in version 3.2.

Parameters:

title (Optional[str])

title(self) str[source]

Returns the current title field for the metadata.

See also

setTitle()

See also

titleChanged()

Added in version 3.2.

Return type:

str

signal titleChanged(title: str)[source]

Emitted when the title field is changed.

See also

title()

See also

setTitle()

Added in version 3.2.

Parameters:

title (str)