Subgroup: Edit
Class: QgsEditFormConfig¶
-
class
qgis.core.
QgsEditFormConfig
(o: QgsEditFormConfig)¶ Bases:
sip.wrapper
Copy constructor
New in version 3.0.
QgsEditFormConfig() Create a new edit form config. Normally invoked by
QgsVectorLayer
Methods
addTab
Adds a new element to the invisible root container in the layout. attributeEditorElementFromDomElement
Deserialize drag and drop designer elements. clearTabs
Clears all the tabs for the attribute editor form with EditorLayout.TabLayout. initCode
Get Python code for edit form initialization. initCodeSource
Return Python code source for edit form initialization initFilePath
Get Python external file path for edit form initialization. initFunction
Get Python function for edit form initialization. invisibleRootContainer
Get the invisible root container for the drag and drop designer form (EditorLayout.TabLayout). labelOnTop
If this returns true, the widget at the given index will receive its label on the previous line while if it returns false, the widget will receive its label on the left hand side. layout
Get the active layout style for the attribute editor for this layer readOnly
This returns true if the field is manually set to read only or if the field does not support editing like joins or virtual fields. readXml
Read XML information removeWidgetConfig
Remove the configuration for the editor widget with the given name setInitCode
Set Python code for edit form initialization. setInitCodeSource
Set if Python code shall be used for edit form initialization and its origin setInitFilePath
Set Python external file path for edit form initialization. setInitFunction
Set Python function for edit form initialization. setLabelOnTop
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 to false, the widget will receive its label on the left hand side. setLayout
Set the active layout style for the attribute editor for this layer setReadOnly
If set to false, the widget at the given index will be read-only. setSuppress
Set type of feature form pop-up suppression after feature creation (overrides app setting) setUiForm
Set path to the .ui form. setWidgetConfig
Set the editor widget config for a widget which is not for a simple field. suppress
Type of feature form pop-up suppression after feature creation (overrides app setting) tabs
Returns a list of tabs for EditorLayout.TabLayout obtained from the invisible root container. uiForm
Get path to the .ui form. widgetConfig
Get the configuration for the editor widget with the given name. writeXml
Write XML information Attributes
CodeSourceDialog
CodeSourceEnvironment
CodeSourceFile
CodeSourceNone
GeneratedLayout
SuppressDefault
SuppressOff
SuppressOn
TabLayout
UiFileLayout
-
CodeSourceDialog
= 2¶
-
CodeSourceEnvironment
= 3¶
-
CodeSourceFile
= 1¶
-
CodeSourceNone
= 0¶
-
class
EditorLayout
¶ Bases:
int
-
class
FeatureFormSuppress
¶ Bases:
int
-
GeneratedLayout
= 0¶
-
class
GroupData
¶ Bases:
sip.wrapper
Constructor for GroupData
QgsEditFormConfig.GroupData(name: str, fields: Iterable[str])
QgsEditFormConfig.GroupData(QgsEditFormConfig.GroupData)
-
mFields
¶
-
mName
¶
-
-
class
PythonInitCodeSource
¶ Bases:
int
-
SuppressDefault
= 0¶
-
SuppressOff
= 2¶
-
SuppressOn
= 1¶
-
class
TabData
¶ Bases:
sip.wrapper
Constructor for TabData
QgsEditFormConfig.TabData(name: str, fields: Iterable[str], groups: Iterable[QgsEditFormConfig.GroupData])
QgsEditFormConfig.TabData(QgsEditFormConfig.TabData)
-
mFields
¶
-
mGroups
¶
-
mName
¶
-
-
TabLayout
= 1¶
-
UiFileLayout
= 2¶
-
addTab
(self, data: QgsAttributeEditorElement)¶ Adds a new element to the invisible root container in the layout.
This is only useful in combination with EditorLayout.TabLayout.
-
attributeEditorElementFromDomElement
(self, elem: QDomElement, parent: QgsAttributeEditorElement) → QgsAttributeEditorElement¶ Deserialize drag and drop designer elements.
-
clearTabs
(self)¶ Clears all the tabs for the attribute editor form with EditorLayout.TabLayout.
-
initCode
(self) → str¶ Get Python code for edit form initialization.
-
initCodeSource
(self) → QgsEditFormConfig.PythonInitCodeSource¶ Return 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)
-
initFilePath
(self) → str¶ Get Python external file path for edit form initialization.
-
initFunction
(self) → str¶ Get 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().
-
invisibleRootContainer
(self) → QgsAttributeEditorContainer¶ Get the invisible root container for the drag and drop designer form (EditorLayout.TabLayout).
New in version 3.
-
labelOnTop
(self, idx: int) → bool¶ If this returns true, the widget at the given index will receive its label on the previous line while if it returns false, the widget will receive its label on the left hand side. Labeling on top leaves more horizontal space for the widget itself. *
-
layout
(self) → QgsEditFormConfig.EditorLayout¶ Get the active layout style for the attribute editor for this layer
-
readOnly
(self, idx: int) → bool¶ This returns true if the field is manually set to read only or if the field does not support editing like joins or virtual fields.
-
readXml
(self, node: QDomNode, context: QgsReadWriteContext)¶ Read XML information Deserialize on project load
-
removeWidgetConfig
(self, widgetName: str) → bool¶ Remove the configuration for the editor widget with the given name
Parameters: widgetName – The name of the widget. Returns: true if a configuration has been removed
-
setInitCode
(self, code: str)¶ Set Python code for edit form initialization. Make sure that you also set the appropriate function name in setInitFunction().
-
setInitCodeSource
(self, initCodeSource: QgsEditFormConfig.PythonInitCodeSource)¶ Set if Python code shall be used for edit form initialization and its origin
-
setInitFilePath
(self, filePath: str)¶ Set Python external file path for edit form initialization. Make sure that you also set the appropriate function name in setInitFunction().
-
setInitFunction
(self, function: str)¶ 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().
-
setLabelOnTop
(self, idx: int, onTop: bool)¶ 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 to false, the widget will receive its label on the left hand side. Labeling on top leaves more horizontal space for the widget itself. *
-
setLayout
(self, editorLayout: QgsEditFormConfig.EditorLayout)¶ Set the active layout style for the attribute editor for this layer
-
setReadOnly
(self, idx: int, readOnly: bool = True)¶ If set to false, the widget at the given index will be read-only.
-
setSuppress
(self, s: QgsEditFormConfig.FeatureFormSuppress)¶ Set type of feature form pop-up suppression after feature creation (overrides app setting)
-
setUiForm
(self, ui: str)¶ Set path to the .ui form. When a string is provided, 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.
-
setWidgetConfig
(self, widgetName: str, config: Dict[str, Any]) → bool¶ Set the editor widget config for a widget which is not for a simple field.
Example: .. code-block:: python
editFormConfig = layer.editFormConfig() editFormConfig.setWidgetConfig( ‘relation_id’, { ‘nm-rel’: ‘other_relation’ } ) layer.setEditFormConfig(editFormConfig)Parameters: - widgetName – The name of the widget to configure
- config – The config to set for this widget
Returns: false if a field exists with the provided widgetName. In this case
QgsVectorLayer.setEditorWidgetSetup should be used.
-
suppress
(self) → QgsEditFormConfig.FeatureFormSuppress¶ Type of feature form pop-up suppression after feature creation (overrides app setting)
-
tabs
(self) → List[QgsAttributeEditorElement]¶ Returns a list of tabs for EditorLayout.TabLayout obtained from the invisible root container.
-
uiForm
(self) → str¶ Get path to the .ui form. Only meaningful with EditorLayout.UiFileLayout.
-
widgetConfig
(self, widgetName: str) → Dict[str, Any]¶ Get the configuration for the editor widget with the given name.
Parameters: widgetName – The name of the widget. Returns: The configuration for the editor widget or an empty config if the field does not exist
-
writeXml
(self, node: QDomNode, context: QgsReadWriteContext)¶ Write XML information Serialize on project save
-