Class: QgsEditorWidgetRegistry¶
This class manages all known edit widget factories.
QgsEditorWidgetRegistry is not usually directly created, but
rather accessed through QgsGui.editorWidgetRegistry().
Class Hierarchy¶
Base classes¶
Methods
Create an attribute editor widget wrapper of a given type for a given field. |
|
Creates a configuration widget |
|
Gets access to all registered factories |
|
Gets a factory for the given widget type id. |
|
Find the best editor widget and its configuration for a given field. |
|
Registers all the default widgets. |
|
Gets the human readable name for a widget type |
|
Register a new auto-conf plugin. |
|
Register a new widget factory with the given id |
- class qgis.gui.QgsEditorWidgetRegistry[source]¶
Bases:
QObject- __init__()
Constructor for QgsEditorWidgetRegistry. QgsEditorWidgetRegistry is not usually directly created, but rather accessed through
QgsGui.editorWidgetRegistry().
- create(self, widgetId: str | None, vl: QgsVectorLayer | None, fieldIdx: int, config: Dict[str, Any], editor: QWidget | None, parent: QWidget | None) QgsEditorWidgetWrapper | None[source]¶
Create an attribute editor widget wrapper of a given type for a given field. The editor may be
Noneif you want the widget wrapper to create a default widget.- Parameters:
widgetId (Optional[str]) – The id of the widget type to create an attribute editor for
vl (Optional[QgsVectorLayer]) – The vector layer for which this widget will be created
fieldIdx (int) – The field index on the specified layer for which this widget will be created
config (Dict[str, Any]) – A configuration which should be used for the widget creation
editor (Optional[QWidget]) – An editor widget which will be used instead of an autocreated widget
parent (Optional[QWidget]) – The parent which will be used for the created wrapper and the created widget
- Return type:
Optional[QgsEditorWidgetWrapper]
- Returns:
A new widget wrapper
- create(self, vl: QgsVectorLayer | None, fieldIdx: int, editor: QWidget | None, parent: QWidget | None) QgsEditorWidgetWrapper | None[source]
Create an attribute editor widget wrapper of the best type for a given field. The editor may be
Noneif you want the widget wrapper to create a default widget.- Parameters:
vl (Optional[QgsVectorLayer]) – The vector layer for which this widget will be created
fieldIdx (int) – The field index on the specified layer for which this widget will be created
editor (Optional[QWidget]) – An editor widget which will be used instead of an autocreated widget
parent (Optional[QWidget]) – The parent which will be used for the created wrapper and the created widget
- Return type:
Optional[QgsEditorWidgetWrapper]
- Returns:
A new widget wrapper
- createConfigWidget(self, widgetId: str | None, vl: QgsVectorLayer | None, fieldIdx: int, parent: QWidget | None) QgsEditorConfigWidget | None[source]¶
Creates a configuration widget
- Parameters:
widgetId (Optional[str]) – The id of the widget type to create a configuration widget for
vl (Optional[QgsVectorLayer]) – The vector layer for which this widget will be created
fieldIdx (int) – The field index on the specified layer for which this widget will be created
parent (Optional[QWidget]) – The parent widget for the created widget
- Return type:
Optional[QgsEditorConfigWidget]
- Returns:
A new configuration widget
- createSearchWidget(self, widgetId: str | None, vl: QgsVectorLayer | None, fieldIdx: int, config: Dict[str, Any], parent: QWidget | None) QgsSearchWidgetWrapper | None[source]¶
- Parameters:
widgetId (Optional[str])
vl (Optional[QgsVectorLayer])
fieldIdx (int)
config (Dict[str, Any])
parent (Optional[QWidget])
- Return type:
Optional[QgsSearchWidgetWrapper]
- factories(self) Any¶
Gets access to all registered factories
- Return type:
Any
- Returns:
All ids and factories
- factory(self, widgetId: str | None) QgsEditorWidgetFactory | None[source]¶
Gets a factory for the given widget type id.
- Return type:
Optional[QgsEditorWidgetFactory]
- Returns:
A factory or
Noneif not existent- Parameters:
widgetId (Optional[str])
- findBest(self, vl: QgsVectorLayer | None, fieldName: str | None) QgsEditorWidgetSetup[source]¶
Find the best editor widget and its configuration for a given field.
- Parameters:
vl (Optional[QgsVectorLayer]) – The vector layer for which this widget will be created
fieldName (Optional[str]) – The field name on the specified layer for which this widget will be created
- Return type:
- Returns:
The id of the widget type to use and its config
- initEditors(self, mapCanvas: QgsMapCanvas | None = None, messageBar: QgsMessageBar | None = None)[source]¶
Registers all the default widgets. Only call this once on startup of an application.
- Parameters:
mapCanvas (Optional[QgsMapCanvas] = None) – Specify a map canvas with which the widgets (relation reference) work
messageBar (Optional[QgsMessageBar] = None) – Specify a message bar on which messages by widgets will be shown while working with the map canvas
Note
Not required for plugins, the QGIS application does that already
- name(self, widgetId: str | None) str[source]¶
Gets the human readable name for a widget type
- Parameters:
widgetId (Optional[str]) – The widget type to get the name for
- Return type:
str
- Returns:
A human readable name
- registerAutoConfPlugin(self, plugin: QgsEditorWidgetAutoConfPlugin | None)[source]¶
Register a new auto-conf plugin.
- Parameters:
plugin (Optional[QgsEditorWidgetAutoConfPlugin]) – The plugin (ownership is transferred)
- registerWidget(self, widgetId: str | None, widgetFactory: QgsEditorWidgetFactory | None) bool[source]¶
Register a new widget factory with the given id
- Parameters:
widgetId (Optional[str]) – The id which will be used later to refer to this widget type
widgetFactory (Optional[QgsEditorWidgetFactory]) – The factory which will create this widget type
- Return type:
bool
- Returns:
True, if successful,False, if the widgetId is already in use or widgetFactory isNone