Class: QgsEditorWidgetRegistry

class qgis.gui.QgsEditorWidgetRegistry

Bases: PyQt5.QtCore.QObject

Constructor for QgsEditorWidgetRegistry. QgsEditorWidgetRegistry is not usually directly created, but rather accessed through QgsGui.editorWidgetRegistry().

This class manages all known edit widget factories.

QgsEditorWidgetRegistry is not usually directly created, but rather accessed through QgsGui.editorWidgetRegistry().

Methods

childEvent

connectNotify

create

Create an attribute editor widget wrapper of a given type for a given field.

createConfigWidget

Creates a configuration widget

createSearchWidget

param widgetId

customEvent

disconnectNotify

factories

Gets access to all registered factories

factory

Gets a factory for the given widget type id.

findBest

Find the best editor widget and its configuration for a given field.

initEditors

Registers all the default widgets.

isSignalConnected

name

Gets the human readable name for a widget type

receivers

registerAutoConfPlugin

Register a new auto-conf plugin.

registerWidget

Register a new widget factory with the given id

sender

senderSignalIndex

timerEvent

childEvent(self, QChildEvent)
connectNotify(self, QMetaMethod)
create(self, widgetId: str, vl: QgsVectorLayer, fieldIdx: int, config: Dict[str, Any], editor: QWidget, parent: QWidget)QgsEditorWidgetWrapper

Create an attribute editor widget wrapper of a given type for a given field. The editor may be None if you want the widget wrapper to create a default widget.

Parameters
  • widgetId (str) – The id of the widget type to create an attribute editor for

  • vl (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) – A configuration which should be used for the widget creation

  • editor (QWidget) – An editor widget which will be used instead of an autocreated widget

  • parent (QWidget) – The parent which will be used for the created wrapper and the created widget

Returns

A new widget wrapper

create(self, vl: QgsVectorLayer, fieldIdx: int, editor: QWidget, parent: QWidget) -> QgsEditorWidgetWrapper Create an attribute editor widget wrapper of the best type for a given field. The editor may be None if you want the widget wrapper to create a default widget.

Parameters
  • vl – The vector layer for which this widget will be created

  • fieldIdx – The field index on the specified layer for which this widget will be created

  • editor – An editor widget which will be used instead of an autocreated widget

  • parent – The parent which will be used for the created wrapper and the created widget

Return type

QgsEditorWidgetWrapper

Returns

A new widget wrapper

createConfigWidget(self, widgetId: str, vl: QgsVectorLayer, fieldIdx: int, parent: QWidget)QgsEditorConfigWidget

Creates a configuration widget

Parameters
  • widgetId (str) – The id of the widget type to create a configuration widget for

  • vl (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 (QWidget) – The parent widget for the created widget

Return type

QgsEditorConfigWidget

Returns

A new configuration widget

createSearchWidget(self, widgetId: str, vl: QgsVectorLayer, fieldIdx: int, config: Dict[str, Any], parent: QWidget)QgsSearchWidgetWrapper
Parameters
  • widgetId (str) –

  • vl (QgsVectorLayer) –

  • fieldIdx (int) –

  • config (Dict[str) –

  • parent (QWidget) –

Return type

QgsSearchWidgetWrapper

customEvent(self, QEvent)
disconnectNotify(self, QMetaMethod)
factories(self)object

Gets access to all registered factories

Return type

object

Returns

All ids and factories

factory(self, widgetId: str)QgsEditorWidgetFactory

Gets a factory for the given widget type id.

Return type

QgsEditorWidgetFactory

Returns

A factory or None if not existent

Parameters

widgetId (str) –

findBest(self, vl: QgsVectorLayer, fieldName: str)QgsEditorWidgetSetup

Find the best editor widget and its configuration for a given field.

Parameters
  • vl (QgsVectorLayer) – The vector layer for which this widget will be created

  • fieldName (str) – The field name on the specified layer for which this widget will be created

Return type

QgsEditorWidgetSetup

Returns

The id of the widget type to use and its config

initEditors(self, mapCanvas: QgsMapCanvas = None, messageBar: QgsMessageBar = None)

Registers all the default widgets. Only call this once on startup of an application.

Parameters
  • mapCanvas (QgsMapCanvas = None) – Specify a map canvas with which the widgets (relation reference) work

  • messageBar (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

New in version 2.8.

isSignalConnected(self, QMetaMethod)bool
name(self, widgetId: str)str

Gets the human readable name for a widget type

Parameters

widgetId (str) – The widget type to get the name for

Return type

str

Returns

A human readable name

receivers(self, PYQT_SIGNAL)int
registerAutoConfPlugin(self, plugin: QgsEditorWidgetAutoConfPlugin)

Register a new auto-conf plugin.

Parameters

plugin (QgsEditorWidgetAutoConfPlugin) – The plugin (ownership is transferred)

registerWidget(self, widgetId: str, widgetFactory: QgsEditorWidgetFactory)bool

Register a new widget factory with the given id

Parameters
  • widgetId (str) – The id which will be used later to refer to this widget type

  • widgetFactory (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 is None

sender(self)QObject
senderSignalIndex(self)int
timerEvent(self, QTimerEvent)