QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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
6  Email : [email protected]
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 <QComboBox>
20 
21 #include "qgsfieldproxymodel.h"
22 #include "qgis_gui.h"
23 
24 #include "qgis_sip.h"
25 
26 class QgsMapLayer;
27 class QgsVectorLayer;
28 
37 class GUI_EXPORT QgsFieldComboBox : public QComboBox
38 {
39  Q_OBJECT
40  Q_PROPERTY( QgsFieldProxyModel::Filters filters READ filters WRITE setFilters )
41  Q_PROPERTY( bool allowEmptyFieldName READ allowEmptyFieldName WRITE setAllowEmptyFieldName )
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 
62  void setAllowEmptyFieldName( bool allowEmpty );
63 
69  bool allowEmptyFieldName() const;
70 
72  QString currentField() const;
73 
78  QgsVectorLayer *layer() const;
79 
80  signals:
82  void fieldChanged( const QString &fieldName );
83 
84  public slots:
85 
91  void setLayer( QgsMapLayer *layer );
92 
94  void setField( const QString &fieldName );
95 
96  protected slots:
97  void indexChanged( int i );
98 
99  private:
100  QgsFieldProxyModel *mFieldProxyModel = nullptr;
101 };
102 
103 #endif // QGSFIELDCOMBOBOX_H
Base class for all map layer types.
Definition: qgsmaplayer.h:79
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
The QgsFieldComboBox is a combo box which displays the list of fields of a given layer.
The QgsFieldProxyModel class provides an easy to use model to display the list of fields of a layer...
const Filters & filters() const
Returns the filters controlling displayed fields.
Represents a vector layer which manages a vector based data sets.