QGIS API Documentation 3.37.0-Master (49cede7946b)
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 <QComboBox>
20
21#include "qgsfieldproxymodel.h"
22#include "qgis_gui.h"
23
24#include "qgis_sip.h"
25
26class QgsMapLayer;
27class QgsVectorLayer;
28class QgsFields;
29
37class 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
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
The QgsFieldComboBox is a combo box which displays the list of fields of a given layer.
void fieldChanged(const QString &fieldName)
Emitted when the currently selected field changes.
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.
QFlags< Filter > Filters
Container of fields for a vector layer.
Definition qgsfields.h:46
Base class for all map layer types.
Definition qgsmaplayer.h:75
Represents a vector layer which manages a vector based data sets.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53