Class: QgsEditFormConfig¶
Contains configuration settings for an editor form.
Enums
Data defined properties. |
|
alias of |
|
alias of |
|
alias of |
Methods
Adds a new element to the invisible root container in the layout. |
|
Deserialize drag and drop designer elements. |
|
Clears all the tabs for the attribute editor form with EditorLayout.TabLayout. |
|
Returns data defined properties for fieldName |
|
Gets Python code for edit form initialization. |
|
Returns Python code source for edit form initialization (if it shall be loaded from a file, read from the provided dialog editor or inherited from the environment) |
|
Gets Python external file path for edit form initialization. |
|
Gets Python function for edit form initialization. |
|
Gets the invisible root container for the drag and drop designer form (EditorLayout.TabLayout). |
|
If this returns |
|
Gets the active layout style for the attribute editor for this layer |
|
Returns data defined property definitions. |
|
This returns |
|
Read XML information Deserialize on project load |
|
Remove the configuration for the editor widget with the given name |
|
If this returns |
|
Set data defined properties for fieldName to properties |
|
Set Python code for edit form initialization. |
|
Sets if Python code shall be used for edit form initialization and its origin |
|
Set Python external file path for edit form initialization. |
|
Set Python function for edit form initialization. |
|
If this is set to |
|
Sets the active layout style for the attribute editor for this layer |
|
If set to |
|
Sets whether the widget at the given index will remember the previously entered value from this QGIS session when creating new features. |
|
Sets type of feature form pop-up suppression after feature creation (overrides app setting) |
|
Set path to the .ui form. |
|
Set the editor widget config for a widget which is not for a simple field. |
|
Type of feature form pop-up suppression after feature creation (overrides app setting) |
|
Returns a list of tabs for EditorLayout.TabLayout obtained from the invisible root container. |
|
Returns the path or URL to the .ui form. |
|
Gets the configuration for the editor widget with the given name. |
|
Write XML information Serialize on project save |
- class qgis.core.QgsEditFormConfig[source]¶
Bases:
object- __init__(o: QgsEditFormConfig)
- Parameters:
- __init__()
Create a new edit form config. Normally invoked by
QgsVectorLayer
- class DataDefinedProperty(*values)¶
Bases:
IntEnumData defined properties. Form data defined overrides are stored in a property collection and they can be retrieved using the indexes specified in this enum.
Added in version 3.14.
NoProperty: No propertyAllProperties: All properties for itemAlias: AliasEditable: Editable stateAdded in version 3.30.
- EditorLayout¶
alias of
AttributeFormLayout
- FeatureFormSuppress¶
alias of
AttributeFormSuppression
- class GroupData¶
- class GroupData(name: str | None, fields: Iterable[str | None])
- class GroupData(a0: QgsEditFormConfig.GroupData)
Bases:
object- mFields¶
- mName¶
- PythonInitCodeSource¶
alias of
AttributeFormPythonInitCodeSource
- class TabData¶
- class TabData(name: str | None, fields: Iterable[str | None], groups: Iterable[QgsEditFormConfig.GroupData])
- class TabData(a0: QgsEditFormConfig.TabData)
Bases:
object- mFields¶
- mGroups¶
- mName¶
- addTab(self, data: QgsAttributeEditorElement | None)[source]¶
Adds a new element to the invisible root container in the layout.
This is only useful in combination with EditorLayout.TabLayout.
- Parameters:
data (Optional[QgsAttributeEditorElement])
- attributeEditorElementFromDomElement(self, elem: QDomElement, parent: QgsAttributeEditorElement | None, layerId: str | None = '', context: QgsReadWriteContext = QgsReadWriteContext()) QgsAttributeEditorElement | None[source]¶
Deserialize drag and drop designer elements.
Deprecated since version 3.18: Use
QgsAttributeEditorElement.create instead.- Parameters:
elem (QDomElement)
parent (Optional[QgsAttributeEditorElement])
layerId (Optional[str] = '')
context (
QgsReadWriteContext= QgsReadWriteContext())
- Return type:
Optional[QgsAttributeEditorElement]
- clearTabs(self)[source]¶
Clears all the tabs for the attribute editor form with EditorLayout.TabLayout.
- dataDefinedFieldProperties(self, fieldName: str | None) QgsPropertyCollection[source]¶
Returns data defined properties for
fieldNameAdded in version 3.14.
- Parameters:
fieldName (Optional[str])
- Return type:
- initCodeSource(self) Qgis.AttributeFormPythonInitCodeSource[source]¶
Returns Python code source for edit form initialization (if it shall be loaded from a file, read from the provided dialog editor or inherited from the environment)
- Return type:
- initFilePath(self) str[source]¶
Gets Python external file path for edit form initialization.
- Return type:
str
- initFunction(self) str[source]¶
Gets Python function for edit form initialization. Will be looked up in a Python file relative to the project folder if it includes a module name or if it’s a pure function name it will searched in the Python code set with
setInitCode().- Return type:
str
- invisibleRootContainer(self) QgsAttributeEditorContainer | None[source]¶
Gets the invisible root container for the drag and drop designer form (EditorLayout.TabLayout).
Added in version 3.
- Return type:
Optional[QgsAttributeEditorContainer]
- labelOnTop(self, idx: int) bool[source]¶
If this returns
True, the widget at the given index will receive its label on the previous line while if it returnsFalse, the widget will receive its label on the left hand side. Labeling on top leaves more horizontal space for the widget itself.- Parameters:
idx (int)
- Return type:
bool
- layout(self) Qgis.AttributeFormLayout[source]¶
Gets the active layout style for the attribute editor for this layer
- Return type:
- propertyDefinitions() Dict[int, QgsPropertyDefinition]¶
Returns data defined property definitions.
Added in version 3.14.
- Return type:
Dict[int, QgsPropertyDefinition]
- readOnly(self, idx: int) bool[source]¶
This returns
Trueif the field is manually set to read only or if the field does not support editing like joins or virtual fields.- Parameters:
idx (int)
- Return type:
bool
- readXml(self, node: QDomNode, context: QgsReadWriteContext)[source]¶
Read XML information Deserialize on project load
- Parameters:
node (QDomNode)
context (QgsReadWriteContext)
- removeWidgetConfig(self, widgetName: str | None) bool[source]¶
Remove the configuration for the editor widget with the given name
- Parameters:
widgetName (Optional[str]) – The name of the widget.
- Return type:
bool
- Returns:
Trueif a configuration has been removed
- reuseLastValue(self, index: int) bool[source]¶
If this returns
True, the widget at the givenindexwill remember the previously entered value from this QGIS session when creating new features.See also
Added in version 3.20.
- Parameters:
index (int)
- Return type:
bool
- setDataDefinedFieldProperties(self, fieldName: str | None, properties: QgsPropertyCollection)[source]¶
Set data defined properties for
fieldNametopropertiesAdded in version 3.14.
- Parameters:
fieldName (Optional[str])
properties (QgsPropertyCollection)
- setInitCode(self, code: str | None)[source]¶
Set Python code for edit form initialization. Make sure that you also set the appropriate function name in
setInitFunction().- Parameters:
code (Optional[str])
- setInitCodeSource(self, initCodeSource: Qgis.AttributeFormPythonInitCodeSource)[source]¶
Sets if Python code shall be used for edit form initialization and its origin
- Parameters:
initCodeSource (Qgis.AttributeFormPythonInitCodeSource)
- setInitFilePath(self, filePath: str | None)[source]¶
Set Python external file path for edit form initialization. Make sure that you also set the appropriate function name in
setInitFunction().- Parameters:
filePath (Optional[str])
- setInitFunction(self, function: str | None)[source]¶
Set Python function for edit form initialization. Will be looked up in a Python file relative to the project folder if it includes a module name or if it’s a pure function name it will searched in the Python code set with
setInitCode().- Parameters:
function (Optional[str])
- setLabelOnTop(self, idx: int, onTop: bool)[source]¶
If this is set to
True, the widget at the given index will receive its label on the previous line while if it is set toFalse, the widget will receive its label on the left hand side. Labeling on top leaves more horizontal space for the widget itself.- Parameters:
idx (int)
onTop (bool)
- setLayout(self, editorLayout: Qgis.AttributeFormLayout)[source]¶
Sets the active layout style for the attribute editor for this layer
- Parameters:
editorLayout (Qgis.AttributeFormLayout)
- setReadOnly(self, idx: int, readOnly: bool = True)[source]¶
If set to
False, the widget at the given index will be read-only.- Parameters:
idx (int)
readOnly (bool = True)
- setReuseLastValue(self, index: int, reuse: bool)[source]¶
Sets whether the widget at the given
indexwill remember the previously entered value from this QGIS session when creating new features.See also
Added in version 3.20.
- Parameters:
index (int)
reuse (bool)
- setSuppress(self, s: Qgis.AttributeFormSuppression)[source]¶
Sets type of feature form pop-up suppression after feature creation (overrides app setting)
- Parameters:
- setUiForm(self, ui: str | None)[source]¶
Set path to the .ui form. When a string is provided in
ui, the layout style will be set to EditorLayout.UiFileLayout, if an empty or a null string is provided, the layout style will be set to EditorLayout.GeneratedLayout. Ifuiis a URL, a local copy of the file will be made and will be used to create the formscontextis provided to save error messages- Parameters:
ui (Optional[str])
- setWidgetConfig(self, widgetName: str | None, config: Dict[str, Any]) bool[source]¶
Set the editor widget config for a widget which is not for a simple field.
Example¶
editFormConfig = layer.editFormConfig() editFormConfig.setWidgetConfig( 'relation_id', { 'nm-rel': 'other_relation' } ) layer.setEditFormConfig(editFormConfig)
- type widgetName:
Optional[str]
- param widgetName:
The name of the widget to configure
- type config:
Dict[str, Any]
- param config:
The config to set for this widget
- rtype:
bool
- return:
Falseif a field exists with the provided widgetName. In this caseQgsVectorLayer.setEditorWidgetSetup should be used.
See also
QgsVectorLayer.setEditorWidgetSetup()for field configurations.
- suppress(self) Qgis.AttributeFormSuppression[source]¶
Type of feature form pop-up suppression after feature creation (overrides app setting)
- Return type:
- tabs(self) List[QgsAttributeEditorElement]¶
Returns a list of tabs for EditorLayout.TabLayout obtained from the invisible root container.
- Return type:
- uiForm(self) str[source]¶
Returns the path or URL to the .ui form. Only meaningful with EditorLayout.UiFileLayout
- Return type:
str
- widgetConfig(self, widgetName: str | None) Dict[str, Any][source]¶
Gets the configuration for the editor widget with the given name.
- Parameters:
widgetName (Optional[str]) – The name of the widget.
- Return type:
Dict[str, Any]
- Returns:
The configuration for the editor widget or an empty config if the field does not exist
- writeXml(self, node: QDomNode, context: QgsReadWriteContext)[source]¶
Write XML information Serialize on project save
- Parameters:
node (QDomNode)
context (QgsReadWriteContext)