17#include "moc_qgsfieldcombobox.cpp"
27 setModel( mFieldProxyModel );
74 const QModelIndex proxyIdx = mFieldProxyModel->mapFromSource( idx );
75 if ( proxyIdx.isValid() )
77 setCurrentIndex( proxyIdx.row() );
81 setCurrentIndex( -1 );
86 setCurrentIndex( -1 );
95 const int i = currentIndex();
97 const QModelIndex proxyIndex = mFieldProxyModel->index( i, 0 );
98 if ( !proxyIndex.isValid() )
void setFilters(QgsFieldProxyModel::Filters filters)
setFilters allows filtering according to the type of field
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes.
void setFields(const QgsFields &fields)
Manually sets the fields to use for the combo box.
void setLayer(QgsMapLayer *layer)
Sets the layer for which fields are listed in the combobox.
QgsFieldProxyModel::Filters filters
QString currentField() const
Returns the currently selected field.
QgsFields fields() const
Returns the fields currently shown in the combobox.
QgsVectorLayer * layer() const
Returns the layer currently associated with the combobox.
void setField(const QString &fieldName)
setField sets the currently selected field
QgsFieldComboBox(QWidget *parent=nullptr)
QgsFieldComboBox creates a combo box to display the fields of a layer.
void setAllowEmptyFieldName(bool allowEmpty)
Sets whether an optional empty field ("not set") option is shown in the combo box.
@ FieldName
Return field name if index corresponds to a field.
void setLayer(QgsVectorLayer *layer)
Set the layer from which fields are displayed.
QgsFields fields() const
Returns the fields currently shown in the model.
void setFields(const QgsFields &fields)
Manually sets the fields to use for the model.
QModelIndex indexFromName(const QString &fieldName)
Returns the index corresponding to a given fieldName.
void setAllowEmptyFieldName(bool allowEmpty)
Sets whether an optional empty field ("not set") option is present in the model.
A proxy model to filter the list of fields of a layer.
QgsFieldModel * sourceFieldModel()
Returns the QgsFieldModel used in this QSortFilterProxyModel.
QgsFieldProxyModel * setFilters(QgsFieldProxyModel::Filters filters)
Set flags that affect how fields are filtered in the model.
Container of fields for a vector layer.
Base class for all map layer types.
Represents a vector layer which manages a vector based dataset.