QgsEditorWidgetRegistry class
This class manages all known edit widget factories.
Contents
QgsEditorWidgetRegistry is not usually directly created, but rather accessed through QgsGui::
Constructors, destructors, conversion operators
- QgsEditorWidgetRegistry()
- Constructor for QgsEditorWidgetRegistry.
- ~QgsEditorWidgetRegistry() override
- Destructor.
Public functions
- auto create(const QString& widgetId, QgsVectorLayer* vl, int fieldIdx, const QVariantMap& config, QWidget* editor, QWidget* parent, const QgsAttributeEditorContext& context = QgsAttributeEditorContext()) -> QgsEditorWidgetWrapper*
- Create an attribute editor widget wrapper of a given type for a given field.
- auto create(QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent, const QgsAttributeEditorContext& context = QgsAttributeEditorContext()) -> QgsEditorWidgetWrapper*
- Create an attribute editor widget wrapper of the best type for a given field.
- auto createConfigWidget(const QString& widgetId, QgsVectorLayer* vl, int fieldIdx, QWidget* parent) -> QgsEditorConfigWidget*
- Creates a configuration widget.
- auto factories() -> QMap<QString, QgsEditorWidgetFactory*>
- Gets access to all registered factories.
- auto factory(const QString& widgetId) -> QgsEditorWidgetFactory*
- Gets a factory for the given widget type id.
- auto findBest(const QgsVectorLayer* vl, const QString& fieldName) const -> QgsEditorWidgetSetup
- Find the best editor widget and its configuration for a given field.
- void initEditors(QgsMapCanvas* mapCanvas = nullptr, QgsMessageBar* messageBar = nullptr)
- Registers all the default widgets.
- auto name(const QString& widgetId) -> QString
- Gets the human readable name for a widget type.
- void registerAutoConfPlugin(QgsEditorWidgetAutoConfPlugin* plugin)
- Register a new auto-conf plugin.
- auto registerWidget(const QString& widgetId, QgsEditorWidgetFactory* widgetFactory) -> bool
- Register a new widget factory with the given id.
Function documentation
QgsEditorWidgetRegistry:: QgsEditorWidgetRegistry()
Constructor for QgsEditorWidgetRegistry.
QgsEditorWidgetRegistry is not usually directly created, but rather accessed through QgsGui::
QgsEditorWidgetRegistry:: ~QgsEditorWidgetRegistry() override
Destructor.
Deletes all the registered widgets
QgsEditorWidgetWrapper* QgsEditorWidgetRegistry:: create(const QString& widgetId,
QgsVectorLayer* vl,
int fieldIdx,
const QVariantMap& config,
QWidget* editor,
QWidget* parent,
const QgsAttributeEditorContext& context = QgsAttributeEditorContext())
Create an attribute editor widget wrapper of a given type for a given field.
| Parameters | |
|---|---|
| widgetId | The id of the widget type to create an attribute editor for |
| 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 |
| config | A configuration which should be used for the widget creation |
| 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 |
| context | The editor context (not available in Python bindings) |
| Returns | A new widget wrapper |
The editor may be NULL if you want the widget wrapper to create a default widget.
QgsEditorWidgetWrapper* QgsEditorWidgetRegistry:: create(QgsVectorLayer* vl,
int fieldIdx,
QWidget* editor,
QWidget* parent,
const QgsAttributeEditorContext& context = QgsAttributeEditorContext())
Create an attribute editor widget wrapper of the best type for a given field.
| 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 |
| context | The editor context (not available in Python bindings) |
| Returns | A new widget wrapper |
The editor may be NULL if you want the widget wrapper to create a default widget.
QgsEditorConfigWidget* QgsEditorWidgetRegistry:: createConfigWidget(const QString& widgetId,
QgsVectorLayer* vl,
int fieldIdx,
QWidget* parent)
Creates a configuration widget.
| Parameters | |
|---|---|
| widgetId | The id of the widget type to create a configuration widget for |
| 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 |
| parent | The parent widget for the created widget |
| Returns | A new configuration widget |
QMap<QString, QgsEditorWidgetFactory*> QgsEditorWidgetRegistry:: factories()
Gets access to all registered factories.
| Returns | All ids and factories |
|---|
QgsEditorWidgetFactory* QgsEditorWidgetRegistry:: factory(const QString& widgetId)
Gets a factory for the given widget type id.
| Returns | A factory or Null if not existent |
|---|
QgsEditorWidgetSetup QgsEditorWidgetRegistry:: findBest(const QgsVectorLayer* vl,
const QString& fieldName) const
Find the best editor widget and its configuration for a given field.
| Parameters | |
|---|---|
| vl | The vector layer for which this widget will be created |
| fieldName | The field name on the specified layer for which this widget will be created |
| Returns | The id of the widget type to use and its config |
void QgsEditorWidgetRegistry:: initEditors(QgsMapCanvas* mapCanvas = nullptr,
QgsMessageBar* messageBar = nullptr)
Registers all the default widgets.
| Parameters | |
|---|---|
| mapCanvas | Specify a map canvas with which the widgets (relation reference) work |
| messageBar | Specify a message bar on which messages by widgets will be shown while working with the map canvas |
Only call this once on startup of an application.
QString QgsEditorWidgetRegistry:: name(const QString& widgetId)
Gets the human readable name for a widget type.
| Parameters | |
|---|---|
| widgetId | The widget type to get the name for |
| Returns | A human readable name |
void QgsEditorWidgetRegistry:: registerAutoConfPlugin(QgsEditorWidgetAutoConfPlugin* plugin)
Register a new auto-conf plugin.
| Parameters | |
|---|---|
| plugin | The plugin (ownership is transferred) |
bool QgsEditorWidgetRegistry:: registerWidget(const QString& widgetId,
QgsEditorWidgetFactory* widgetFactory)
Register a new widget factory with the given id.
| Parameters | |
|---|---|
| widgetId | The id which will be used later to refer to this widget type |
| widgetFactory | The factory which will create this widget type |
| Returns | true, if successful, false, if the widgetId is already in use or widgetFactory is NULL |