QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsfieldcombobox.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsfieldcombobox.h
3 --------------------------------------
4 Date : 01.04.2014
5 Copyright : (C) 2014 Denis Rouzaud
7***************************************************************************
8* *
9* This program is free software; you can redistribute it and/or modify *
10* it under the terms of the GNU General Public License as published by *
11* the Free Software Foundation; either version 2 of the License, or *
12* (at your option) any later version. *
13* *
14***************************************************************************/
15
16#ifndef QGSFIELDCOMBOBOX_H
17#define QGSFIELDCOMBOBOX_H
18
19#include "qgis_gui.h"
20#include "qgis_sip.h"
21#include "qgsfieldproxymodel.h"
22
23#include <QComboBox>
24
25class QgsMapLayer;
26class QgsVectorLayer;
27class QgsFields;
28
37class GUI_EXPORT QgsFieldComboBox : public QComboBox
38{
39 Q_OBJECT
42
43 public:
44
49 explicit QgsFieldComboBox( QWidget *parent SIP_TRANSFERTHIS = nullptr );
50
52 void setFilters( QgsFieldProxyModel::Filters filters );
53
55 QgsFieldProxyModel::Filters filters() const { return mFieldProxyModel->filters(); }
56
61 void setAllowEmptyFieldName( bool allowEmpty );
62
67 bool allowEmptyFieldName() const;
68
70 QString currentField() const;
71
76 QgsVectorLayer *layer() const;
77
88 void setFields( const QgsFields &fields );
89
98 QgsFields fields() const;
99
100 signals:
102 void fieldChanged( const QString &fieldName );
103
104 public slots:
105
111 void setLayer( QgsMapLayer *layer );
112
114 void setField( const QString &fieldName );
115
116 protected slots:
117 void indexChanged( int i );
118
119 private:
120 QgsFieldProxyModel *mFieldProxyModel = nullptr;
121};
122
123#endif // QGSFIELDCOMBOBOX_H
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 setLayer(QgsMapLayer *layer)
Sets the layer for which fields are listed in the combobox.
QgsFieldProxyModel::Filters filters
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.
A proxy model to filter the list of fields of a layer.
QFlags< Filter > Filters
Container of fields for a vector layer.
Definition qgsfields.h:46
Base class for all map layer types.
Definition qgsmaplayer.h:80
Represents a vector layer which manages a vector based dataset.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53