Class: QgsAnnotationItemBaseWidget

A base class for property widgets for annotation items.

All annotation item widgets should inherit from this base class.

Added in version 3.22.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsAnnotationItemBaseWidget

Base classes

QgsPanelWidget

Base class for any widget that can be shown as a inline panel

QWidget

QObject

QPaintDevice

Methods

context

Returns the context in which the widget is shown, e.g., the associated map canvas and expression contexts.

createItem

Creates a new item matching the settings defined in the widget.

focusDefaultWidget

Focuses the default widget for the page.

itemId

Returns the associated annotation item id.

layer

Returns the associated annotation map layer.

renderedItemDetails

Retrieve rendered annotation details for the associated annotation, if available.

setContext

Sets the context in which the widget is shown, e.g., the associated map canvas and expression contexts.

setItem

Sets the current item to show in the widget.

setItemId

Sets the associated annotation item id.

setLayer

Sets the associated annotation map layer.

setNewItem

Attempts to update the widget to show the properties for the specified item.

updateItem

Updates an existing item to match the settings defined in the widget.

Signals

itemChanged

Emitted when the annotation item definition in the widget is changed by the user.

class qgis.gui.QgsAnnotationItemBaseWidget[source]

Bases: QgsPanelWidget

__init__(parent: QWidget | None)

Constructor for QgsAnnotationItemBaseWidget.

Parameters:

parent (Optional[QWidget])

context(self) QgsSymbolWidgetContext[source]

Returns the context in which the widget is shown, e.g., the associated map canvas and expression contexts.

See also

setContext()

Return type:

QgsSymbolWidgetContext

createItem(self) QgsAnnotationItem | None[source]

Creates a new item matching the settings defined in the widget.

Return type:

Optional[QgsAnnotationItem]

focusDefaultWidget(self)[source]

Focuses the default widget for the page.

signal itemChanged[source]

Emitted when the annotation item definition in the widget is changed by the user.

itemId(self) str[source]

Returns the associated annotation item id.

See also

setItemId()

Added in version 3.40.

Return type:

str

layer(self) QgsAnnotationLayer | None[source]

Returns the associated annotation map layer.

See also

setLayer()

Added in version 3.40.

Return type:

Optional[QgsAnnotationLayer]

renderedItemDetails(self) QgsRenderedAnnotationItemDetails | None[source]

Retrieve rendered annotation details for the associated annotation, if available.

Added in version 3.40.

Return type:

Optional[QgsRenderedAnnotationItemDetails]

setContext(self, context: QgsSymbolWidgetContext)[source]

Sets the context in which the widget is shown, e.g., the associated map canvas and expression contexts.

See also

context()

Parameters:

context (QgsSymbolWidgetContext)

setItem(self, item: QgsAnnotationItem | None) bool[source]

Sets the current item to show in the widget. If True is returned, item was an acceptable type for display in this widget and the widget has been updated to match item’s properties.

If False is returned, then the widget could not be successfully updated to show the properties of item.

Parameters:

item (Optional[QgsAnnotationItem])

Return type:

bool

setItemId(self, id: str | None)[source]

Sets the associated annotation item id.

See also

itemId()

Added in version 3.40.

Parameters:

id (Optional[str])

setLayer(self, layer: QgsAnnotationLayer | None)[source]

Sets the associated annotation map layer.

See also

layer()

Added in version 3.40.

Parameters:

layer (Optional[QgsAnnotationLayer])

setNewItem(self, item: QgsAnnotationItem | None) bool[source]

Attempts to update the widget to show the properties for the specified item.

Subclasses can override this if they support changing items in place.

Implementations must return True if the item was accepted and the widget was updated.

Parameters:

item (Optional[QgsAnnotationItem])

Return type:

bool

updateItem(self, item: QgsAnnotationItem | None)[source]

Updates an existing item to match the settings defined in the widget.

Parameters:

item (Optional[QgsAnnotationItem])