Class: QgsAttributeEditorElement

An abstract base class for any elements of a drag and drop form.

This can either be a container which will be represented on the screen as a tab widget or a collapsible group box. Or it can be a field which will then be represented based on the QgsEditorWidget type and configuration. Or it can be a relation and embed the form of several children of another layer.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: clone()

Class Hierarchy

Inheritance diagram of qgis.core.QgsAttributeEditorElement

Subclasses

QgsAttributeEditorAction

This element will load a layer action onto the form.

QgsAttributeEditorContainer

A container for attribute editors, used to group them visually in the attribute form if it is set to the drag and drop designer.

QgsAttributeEditorField

This element will load a field’s widget onto the form.

QgsAttributeEditorHtmlElement

An attribute editor widget that will represent arbitrary HTML code.

QgsAttributeEditorQmlElement

An attribute editor widget that will represent arbitrary QML code.

QgsAttributeEditorRelation

This element will load a relation editor onto the form.

QgsAttributeEditorSpacerElement

An attribute editor widget that will represent a spacer.

QgsAttributeEditorTextElement

An attribute editor widget that will represent arbitrary text code.

Enums

AttributeEditorType

Attribute editor types.

Abstract Methods

clone

Returns a clone of this element.

Methods

horizontalStretch

Returns the horizontal stretch factor for the element.

labelStyle

Returns the label style.

name

Returns the name of this element

parent

Gets the parent of this element.

setHorizontalStretch

Sets the horizontal stretch factor for the element.

setLabelStyle

Sets the labelStyle.

setShowLabel

Controls if this element should be labeled with a title (field, relation or groupname).

setVerticalStretch

Sets the vertical stretch factor for the element.

showLabel

Controls if this element should be labeled with a title (field, relation or groupname).

toDomElement

Gets the XML Dom element to save this element.

type

The type of this element

verticalStretch

Returns the vertical stretch factor for the element.

Static Methods

create

Constructs the editor element from the given element

class qgis.core.QgsAttributeEditorElement[source]

Bases: object

__init__(type: Qgis.AttributeEditorType, name: str | None, parent: QgsAttributeEditorElement | None = None)

Constructor

Parameters:
__init__(a0: QgsAttributeEditorElement)
Parameters:

a0 (QgsAttributeEditorElement)

class AttributeEditorType(*values)

Bases: IntEnum

Attribute editor types.

Note

Prior to QGIS 3.32 this was available as QgsAttributeEditorElement.AttributeEditorType.

Added in version 3.32.

  • Container: A container

    Available as QgsAttributeEditorElement.AeTypeContainer in older QGIS releases.

  • Field: A field

    Available as QgsAttributeEditorElement.AeTypeField in older QGIS releases.

  • Relation: A relation

    Available as QgsAttributeEditorElement.AeTypeRelation in older QGIS releases.

  • QmlElement: A QML element

    Available as QgsAttributeEditorElement.AeTypeQmlElement in older QGIS releases.

  • HtmlElement: A HTML element

    Available as QgsAttributeEditorElement.AeTypeHtmlElement in older QGIS releases.

  • Action: A layer action element

    Added in version 3.22.

    Available as QgsAttributeEditorElement.AeTypeAction in older QGIS releases.

  • TextElement: A text element

    Added in version 3.30.

    Available as QgsAttributeEditorElement.AeTypeTextElement in older QGIS releases.

  • SpacerElement: A spacer element

    Added in version 3.30.

    Available as QgsAttributeEditorElement.AeTypeSpacerElement in older QGIS releases.

  • Invalid: Invalid

    Available as QgsAttributeEditorElement.AeTypeInvalid in older QGIS releases.

class LabelStyle

Bases: object

The TabStyle struct defines color and font overrides for form fields, tabs and groups labels.

Added in version 3.26.

color: QColor

Label font

font: QFont

Label font

overrideColor: bool

Override label color

overrideFont: bool

Override label font

abstract clone(self, parent: QgsAttributeEditorElement | None) QgsAttributeEditorElement | None[source]

Returns a clone of this element. To be implemented by subclasses.

Parameters:

parent (Optional[QgsAttributeEditorElement])

Return type:

Optional[QgsAttributeEditorElement]

static create(element: QDomElement, layerId: str | None, fields: QgsFields, context: QgsReadWriteContext, parent: QgsAttributeEditorElement | None = None) QgsAttributeEditorElement | None[source]

Constructs the editor element from the given element

Added in version 3.18.

Parameters:
Return type:

Optional[QgsAttributeEditorElement]

horizontalStretch(self) int[source]

Returns the horizontal stretch factor for the element.

Added in version 3.32.

Return type:

int

labelStyle(self) QgsAttributeEditorElement.LabelStyle[source]

Returns the label style.

See also

setLabelStyle()

Added in version 3.26.

Return type:

QgsAttributeEditorElement.LabelStyle

name(self) str[source]

Returns the name of this element

Return type:

str

Returns:

The name for this element

parent(self) QgsAttributeEditorElement | None[source]

Gets the parent of this element.

Return type:

Optional[QgsAttributeEditorElement]

setHorizontalStretch(self, stretch: int)[source]

Sets the horizontal stretch factor for the element.

Added in version 3.32.

Parameters:

stretch (int)

setLabelStyle(self, labelStyle: QgsAttributeEditorElement.LabelStyle)[source]

Sets the labelStyle.

See also

labelStyle()

Added in version 3.26.

Parameters:

labelStyle (QgsAttributeEditorElement.LabelStyle)

setShowLabel(self, showLabel: bool)[source]

Controls if this element should be labeled with a title (field, relation or groupname).

Parameters:

showLabel (bool)

setVerticalStretch(self, stretch: int)[source]

Sets the vertical stretch factor for the element.

Added in version 3.32.

Parameters:

stretch (int)

showLabel(self) bool[source]

Controls if this element should be labeled with a title (field, relation or groupname).

Return type:

bool

toDomElement(self, doc: QDomDocument) QDomElement[source]

Gets the XML Dom element to save this element.

Parameters:

doc (QDomDocument) – The QDomDocument which is used to create new XML elements

Return type:

QDomElement

Returns:

A DOM element to serialize this element

type(self) Qgis.AttributeEditorType[source]

The type of this element

Return type:

Qgis.AttributeEditorType

Returns:

The type

verticalStretch(self) int[source]

Returns the vertical stretch factor for the element.

Added in version 3.32.

Return type:

int