QGIS API Documentation
3.20.0-Odense (decaadbb31)
|
The QgsFieldComboBox is a combo box which displays the list of fields of a given layer. More...
#include <qgsfieldcombobox.h>
Public Slots | |
void | setField (const QString &fieldName) |
setField sets the currently selected field More... | |
void | setLayer (QgsMapLayer *layer) |
Sets the layer for which fields are listed in the combobox. More... | |
Signals | |
void | fieldChanged (const QString &fieldName) |
Emitted when the currently selected field changes. More... | |
Public Member Functions | |
QgsFieldComboBox (QWidget *parent=nullptr) | |
QgsFieldComboBox creates a combo box to display the fields of a layer. More... | |
bool | allowEmptyFieldName () const |
Returns true if the combo box allows the empty field ("not set") choice. More... | |
QString | currentField () const |
Returns the currently selected field. More... | |
QgsFields | fields () const |
Returns the fields currently shown in the combobox. More... | |
QgsFieldProxyModel::Filters | filters () const |
currently used filter on list of fields More... | |
QgsVectorLayer * | layer () const |
Returns the layer currently associated with the combobox. More... | |
void | setAllowEmptyFieldName (bool allowEmpty) |
Sets whether an optional empty field ("not set") option is shown in the combo box. More... | |
void | setFields (const QgsFields &fields) |
Manually sets the fields to use for the combo box. More... | |
void | setFilters (QgsFieldProxyModel::Filters filters) |
setFilters allows filtering according to the type of field More... | |
Protected Slots | |
void | indexChanged (int i) |
Properties | |
bool | allowEmptyFieldName |
QgsFieldProxyModel::Filters | filters |
The QgsFieldComboBox is a combo box which displays the list of fields of a given layer.
It might be combined with a QgsMapLayerComboBox to automatically update fields according to a chosen layer. If expression must be used, QgsFieldExpressionWidget shall be used instead.
Definition at line 38 of file qgsfieldcombobox.h.
|
explicit |
QgsFieldComboBox creates a combo box to display the fields of a layer.
The layer can be either manually given or dynamically set by connecting the signal QgsMapLayerComboBox::layerChanged to the slot setLayer.
Definition at line 22 of file qgsfieldcombobox.cpp.
bool QgsFieldComboBox::allowEmptyFieldName | ( | ) | const |
Returns true
if the combo box allows the empty field ("not set") choice.
Definition at line 41 of file qgsfieldcombobox.cpp.
QString QgsFieldComboBox::currentField | ( | ) | const |
Returns the currently selected field.
Definition at line 92 of file qgsfieldcombobox.cpp.
|
signal |
Emitted when the currently selected field changes.
QgsFields QgsFieldComboBox::fields | ( | ) | const |
Returns the fields currently shown in the combobox.
This will either be fields from the associated layer() or the fields manually set by a call to setFields().
Definition at line 62 of file qgsfieldcombobox.cpp.
|
inline |
currently used filter on list of fields
Definition at line 56 of file qgsfieldcombobox.h.
|
protectedslot |
Definition at line 106 of file qgsfieldcombobox.cpp.
QgsVectorLayer * QgsFieldComboBox::layer | ( | ) | const |
Returns the layer currently associated with the combobox.
Definition at line 52 of file qgsfieldcombobox.cpp.
void QgsFieldComboBox::setAllowEmptyFieldName | ( | bool | allowEmpty | ) |
Sets whether an optional empty field ("not set") option is shown in the combo box.
Definition at line 36 of file qgsfieldcombobox.cpp.
|
slot |
setField sets the currently selected field
Definition at line 67 of file qgsfieldcombobox.cpp.
void QgsFieldComboBox::setFields | ( | const QgsFields & | fields | ) |
Manually sets the fields to use for the combo box.
This method should only be used when the combo box ISN'T associated with a layer() and needs to show the fields from an arbitrary field collection instead. Calling setFields() will automatically clear any existing layer().
Definition at line 57 of file qgsfieldcombobox.cpp.
void QgsFieldComboBox::setFilters | ( | QgsFieldProxyModel::Filters | filters | ) |
setFilters allows filtering according to the type of field
Definition at line 31 of file qgsfieldcombobox.cpp.
|
slot |
Sets the layer for which fields are listed in the combobox.
If no layer is set or a non-vector layer is set then the combobox will be empty.
Definition at line 46 of file qgsfieldcombobox.cpp.
|
readwrite |
Definition at line 1 of file qgsfieldcombobox.h.
|
readwrite |
Definition at line 1 of file qgsfieldcombobox.h.