QgsListWidgetWrapper class
Wraps a list widget.
Contents
Base classes
- class QgsEditorWidgetWrapper
- Manages an editor widget Widget and wrapper share the same parent.
Constructors, destructors, conversion operators
- QgsListWidgetWrapper(QgsVectorLayer* layer, int fieldIdx, QWidget* editor = nullptr, QWidget* parent = nullptr) explicit
- Constructor for QgsListWidgetWrapper.
Public functions
- void showIndeterminateState() override
- Sets the widget to display in an indeterminate "mixed value" state.
- auto value() const -> QVariant override
- Will be used to access the widget's value.
Protected functions
- auto createWidget(QWidget* parent) -> QWidget* override
- This method should create a new widget with the provided parent.
- void initWidget(QWidget* editor) override
- This method should initialize the editor widget with runtime data.
- auto valid() const -> bool override
- Returns true if the widget has been properly initialized.
Private functions
- void updateConstraintWidgetStatus() override
- This should update the widget with a visual cue if a constraint status changed.
Function documentation
QgsListWidgetWrapper:: QgsListWidgetWrapper(QgsVectorLayer* layer,
int fieldIdx,
QWidget* editor = nullptr,
QWidget* parent = nullptr) explicit
Constructor for QgsListWidgetWrapper.
The layer and fieldIdx arguments specify the vector layer field associated with the wrapper.
The editor argument indicates the editor widget to use with the wrapper. This can be a nullptr if a new widget should be autogenerated.
A parent widget for this widget wrapper and the created widget can also be specified.
void QgsListWidgetWrapper:: showIndeterminateState() override
Sets the widget to display in an indeterminate "mixed value" state.
QVariant QgsListWidgetWrapper:: value() const override
Will be used to access the widget's value.
| Returns | The current value the widget represents |
|---|
Read the value from the widget and return it properly formatted to be saved in the attribute.
If an invalid variant is returned this will be interpreted as no change. Be sure to return a NULL QVariant if it should be set to NULL.
QWidget* QgsListWidgetWrapper:: createWidget(QWidget* parent) override protected
This method should create a new widget with the provided parent.
| Parameters | |
|---|---|
| parent | You should set this parent on the created widget. |
| Returns | A new widget |
This will only be called if the form did not already provide a widget, so it is not guaranteed to be called! You should not do initialization stuff, which also has to be done for custom editor widgets inside this method. Things like filling comboboxes and assigning other data which will also be used to make widgets on forms created in the QtDesigner usable should be assigned in initWidget().
void QgsListWidgetWrapper:: initWidget(QWidget* editor) override protected
This method should initialize the editor widget with runtime data.
| Parameters | |
|---|---|
| editor | The widget which will represent this attribute editor in a form. |
Fill your comboboxes here.
bool QgsListWidgetWrapper:: valid() const override protected
Returns true if the widget has been properly initialized.
| Returns | Validity status of this widget. |
|---|
This acts as hint for the calling party if this wrapper can be used after initializing it. If it cannot be used this is a hint to the caller that he may try to find another suitable widget type instead.
void QgsListWidgetWrapper:: updateConstraintWidgetStatus() override private
This should update the widget with a visual cue if a constraint status changed.
By default a stylesheet will be applied on the widget that changes the background color to red.
This can be overwritten in subclasses to allow individual widgets to change the visual cue.