Class: QgsGeometryWidget

A widget for storing and interacting with a QgsGeometry object.

This widget can be used in places where an dialog needs to expose a geometry value to users, and allow them to safely interact with it (such as changing the stored geometry value).

Added in version 3.30.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsGeometryWidget

Base classes

QWidget

QObject

QPaintDevice

Methods

acceptedWkbTypes

Returns the list of WKB geometry types which are permitted for the widget.

clearGeometry

Clears the current geometry value stored in the widget.

copyAsGeoJson

Copies the current geometry value to the clipboard, as a GeoJSON string.

copyAsWkt

Copies the current geometry value to the clipboard, as a WKT string.

geometryValue

Returns the current geometry value for the widget.

isReadOnly

Returns whether the widget is in a read-only state.

setAcceptedWkbTypes

Sets the list of WKB geometry types which are permitted for the widget.

setGeometryValue

Sets the current geometry value for the widget.

setReadOnly

Sets whether the widget should be in a read-only state.

Signals

geometryValueChanged

Emitted whenever the geometry value of the widget is changed.

class qgis.gui.QgsGeometryWidget[source]

Bases: QWidget

__init__(parent: QWidget | None = None)

Constructor for QgsGeometryWidget, with the specified parent widget.

Parameters:

parent (Optional[QWidget] = None)

acceptedWkbTypes(self) List[Qgis.WkbType]

Returns the list of WKB geometry types which are permitted for the widget.

Return type:

List[Qgis.WkbType]

clearGeometry(self)[source]

Clears the current geometry value stored in the widget.

copyAsGeoJson(self)[source]

Copies the current geometry value to the clipboard, as a GeoJSON string.

See also

copyAsWkt()

copyAsWkt(self)[source]

Copies the current geometry value to the clipboard, as a WKT string.

See also

copyAsGeoJson()

geometryValue(self) QgsReferencedGeometry[source]

Returns the current geometry value for the widget.

Warning

This should not be confused with QWidget.geometry(), which returns the placement and size of the widget itself.

Return type:

QgsReferencedGeometry

signal geometryValueChanged(value: QgsReferencedGeometry)[source]

Emitted whenever the geometry value of the widget is changed.

See also

geometryValue()

Parameters:

value (QgsReferencedGeometry)

isReadOnly(self) bool[source]

Returns whether the widget is in a read-only state.

See also

setReadOnly()

Return type:

bool

setAcceptedWkbTypes(self, types: Iterable[Qgis.WkbType])[source]

Sets the list of WKB geometry types which are permitted for the widget.

Parameters:

types (Iterable[Qgis.WkbType])

setGeometryValue(self, geometry: QgsReferencedGeometry)[source]

Sets the current geometry value for the widget.

Warning

This should not be confused with QWidget.setGeometry(), which modifies the placement and size of the widget itself.

See also

geometryValue()

Parameters:

geometry (QgsReferencedGeometry)

setReadOnly(self, readOnly: bool)[source]

Sets whether the widget should be in a read-only state.

See also

isReadOnly()

Parameters:

readOnly (bool)