Class: QgsAttributeEditorElement

class qgis.core.QgsAttributeEditorElement

Bases: sip.wrapper

This is 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.

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

Parameters:
  • type – The type of the new element.

  • name

  • parent

QgsAttributeEditorElement(QgsAttributeEditorElement)

Enums

AttributeEditorType

Bases: enum.IntEnum

Methods

clone

Returns a clone of this element.

create

Constructs the editor element from the given element

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.

class AttributeEditorType(value)

Bases: enum.IntEnum

Attribute editor types.

Note

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

Added in version 3.32.

  • AeTypeContainer: A container

  • AeTypeField: A field

  • AeTypeRelation: A relation

  • AeTypeQmlElement: A QML element

  • AeTypeHtmlElement: A HTML element

  • AeTypeAction: A layer action element (since QGIS 3.22)

  • AeTypeTextElement: A text element (since QGIS 3.30)

  • AeTypeSpacerElement: A spacer element (since QGIS 3.30)

  • AeTypeInvalid: Invalid

baseClass

alias of Qgis

class LabelStyle
class LabelStyle(QgsAttributeEditorElement.LabelStyle)

Bases: sip.wrapper

color
font
overrideColor
overrideFont
clone(self, parent: QgsAttributeEditorElement) QgsAttributeEditorElement

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

Parameters:

parent (QgsAttributeEditorElement)

Return type:

QgsAttributeEditorElement

create(element: QDomElement, layerId: str, fields: QgsFields, context: QgsReadWriteContext, parent: QgsAttributeEditorElement = None) QgsAttributeEditorElement

Constructs the editor element from the given element

Added in version 3.18.

Parameters:
Return type:

QgsAttributeEditorElement

horizontalStretch(self) int

Returns the horizontal stretch factor for the element.

Added in version 3.32.

Return type:

int

labelStyle(self) QgsAttributeEditorElement.LabelStyle

Returns the label style.

See also

setLabelStyle()

Added in version 3.26.

Return type:

QgsAttributeEditorElement.LabelStyle

name(self) str

Returns the name of this element

Return type:

str

Returns:

The name for this element

parent(self) QgsAttributeEditorElement

Gets the parent of this element.

Return type:

QgsAttributeEditorElement

setHorizontalStretch(self, stretch: int)

Sets the horizontal stretch factor for the element.

Added in version 3.32.

Parameters:

stretch (int)

setLabelStyle(self, labelStyle: QgsAttributeEditorElement.LabelStyle)

Sets the labelStyle.

See also

labelStyle()

Added in version 3.26.

Parameters:

labelStyle (QgsAttributeEditorElement.LabelStyle)

setShowLabel(self, showLabel: bool)

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

Parameters:

showLabel (bool)

setVerticalStretch(self, stretch: int)

Sets the vertical stretch factor for the element.

Added in version 3.32.

Parameters:

stretch (int)

showLabel(self) bool

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

Return type:

bool

toDomElement(self, doc: QDomDocument) QDomElement

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

The type of this element

Return type:

Qgis.AttributeEditorType

Returns:

The type

verticalStretch(self) int

Returns the vertical stretch factor for the element.

Added in version 3.32.

Return type:

int