QGIS API Documentation 3.41.0-Master (af5edcb665c)
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:
48 explicit QgsFieldComboBox( QWidget *parent SIP_TRANSFERTHIS = nullptr );
49
51 void setFilters( QgsFieldProxyModel::Filters filters );
52
54 QgsFieldProxyModel::Filters filters() const { return mFieldProxyModel->filters(); }
55
60 void setAllowEmptyFieldName( bool allowEmpty );
61
66 bool allowEmptyFieldName() const;
67
69 QString currentField() const;
70
75 QgsVectorLayer *layer() const;
76
87 void setFields( const QgsFields &fields );
88
97 QgsFields fields() const;
98
99 signals:
101 void fieldChanged( const QString &fieldName );
102
103 public slots:
104
110 void setLayer( QgsMapLayer *layer );
111
113 void setField( const QString &fieldName );
114
115 protected slots:
116 void indexChanged( int i );
117
118 private:
119 QgsFieldProxyModel *mFieldProxyModel = nullptr;
120};
121
122#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:76
Represents a vector layer which manages a vector based data sets.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53