| 
    QGIS API Documentation 3.99.0-Master (f78f5286a64)
    
   | 
 
A model which displays the list of fields in widgets (optionally associated with a vector layer). More...
#include <qgsfieldmodel.h>

Public Types | |
| enum class | CustomRole : int {  FieldName = Qt::UserRole + 1 , FieldIndex = Qt::UserRole + 2 , Expression = Qt::UserRole + 3 , IsExpression = Qt::UserRole + 4 , ExpressionValidity = Qt::UserRole + 5 , FieldType = Qt::UserRole + 6 , FieldOrigin = Qt::UserRole + 7 , IsEmpty = Qt::UserRole + 8 , EditorWidgetType = Qt::UserRole + 9 , JoinedFieldIsEditable = Qt::UserRole + 10 , FieldIsWidgetEditable = Qt::UserRole + 11 }  | 
| Custom model roles.  More... | |
Public Slots | |
| void | setLayer (QgsVectorLayer *layer) | 
| Set the layer from which fields are displayed.   | |
Public Member Functions | |
| QgsFieldModel (QObject *parent=nullptr) | |
| Constructor for QgsFieldModel - creates a model to display the fields of a given layer.   | |
| bool | allowEmptyFieldName () const | 
Returns true if the model allows the empty field ("not set") choice.   | |
| bool | allowExpression () | 
Returns true if the model allows custom expressions to be created and displayed.   | |
| int | columnCount (const QModelIndex &parent) const override | 
| QVariant | data (const QModelIndex &index, int role) const override | 
| QgsFields | fields () const | 
| Returns the fields currently shown in the model.   | |
| QModelIndex | index (int row, int column, const QModelIndex &parent=QModelIndex()) const override | 
| QModelIndex | indexFromName (const QString &fieldName) | 
| Returns the index corresponding to a given fieldName.   | |
| bool | isField (const QString &expression) const | 
Returns true if a string represents a field reference, or false if it is an expression consisting of more than direct field reference.   | |
| QgsVectorLayer * | layer () | 
| Returns the layer associated with the model.   | |
| QModelIndex | parent (const QModelIndex &child) const override | 
| void | removeExpression () | 
| Removes any custom expression from the model.   | |
| int | rowCount (const QModelIndex &parent=QModelIndex()) const override | 
| void | setAllowEmptyFieldName (bool allowEmpty) | 
| Sets whether an optional empty field ("not set") option is present in the model.   | |
| void | setAllowExpression (bool allowExpression) | 
| Sets whether custom expressions are accepted and displayed in the model.   | |
| void | setExpression (const QString &expression) | 
| Sets a single expression to be added after the fields at the end of the model.   | |
| void | setFields (const QgsFields &fields) | 
| Manually sets the fields to use for the model.   | |
Static Public Member Functions | |
| static QString | fieldToolTip (const QgsField &field) | 
| Returns a HTML formatted tooltip string for a field, containing details like the field name, alias and type.   | |
| static QString | fieldToolTipExtended (const QgsField &field, const QgsVectorLayer *layer) | 
| Returns a HTML formatted tooltip string for a field, containing details like the field name, alias, type and expression.   | |
Protected Slots | |
| virtual void | updateModel () | 
| Called when the model must be updated.   | |
Protected Attributes | |
| bool | mAllowEmpty = false | 
| bool | mAllowExpression = false | 
| QList< QString > | mExpression | 
| QgsFields | mFields | 
| QgsVectorLayer * | mLayer = nullptr | 
Properties | |
| bool | allowEmptyFieldName | 
| bool | allowExpression | 
| QgsVectorLayer * | layer | 
A model which displays the list of fields in widgets (optionally associated with a vector layer).
If allowed, expressions might be added to the end of the model. It can be associated with a QgsMapLayerModel to dynamically display a layer and its fields.
Definition at line 38 of file qgsfieldmodel.h.
      
  | 
  strong | 
Custom model roles.
Definition at line 56 of file qgsfieldmodel.h.
      
  | 
  explicit | 
Constructor for QgsFieldModel - creates a model to display the fields of a given layer.
Definition at line 24 of file qgsfieldmodel.cpp.
      
  | 
  inline | 
Returns true if the model allows the empty field ("not set") choice. 
Definition at line 106 of file qgsfieldmodel.h.
      
  | 
  inline | 
Returns true if the model allows custom expressions to be created and displayed. 
Definition at line 94 of file qgsfieldmodel.h.
      
  | 
  override | 
Definition at line 264 of file qgsfieldmodel.cpp.
      
  | 
  override | 
Definition at line 270 of file qgsfieldmodel.cpp.
| QgsFields QgsFieldModel::fields | ( | ) | const | 
Returns the fields currently shown in the model.
This will either be fields from the associated layer() or the fields manually set by a call to setFields().
Definition at line 526 of file qgsfieldmodel.cpp.
      
  | 
  static | 
Returns a HTML formatted tooltip string for a field, containing details like the field name, alias and type.
Definition at line 473 of file qgsfieldmodel.cpp.
      
  | 
  static | 
Returns a HTML formatted tooltip string for a field, containing details like the field name, alias, type and expression.
Definition at line 497 of file qgsfieldmodel.cpp.
      
  | 
  override | 
Definition at line 238 of file qgsfieldmodel.cpp.
| QModelIndex QgsFieldModel::indexFromName | ( | const QString & | fieldName | ) | 
Returns the index corresponding to a given fieldName.
Definition at line 29 of file qgsfieldmodel.cpp.
| bool QgsFieldModel::isField | ( | const QString & | expression | ) | const | 
Returns true if a string represents a field reference, or false if it is an expression consisting of more than direct field reference. 
Definition at line 74 of file qgsfieldmodel.cpp.
      
  | 
  inline | 
Returns the layer associated with the model.
Definition at line 133 of file qgsfieldmodel.h.
      
  | 
  override | 
Definition at line 248 of file qgsfieldmodel.cpp.
| void QgsFieldModel::removeExpression | ( | ) | 
Removes any custom expression from the model.
Definition at line 231 of file qgsfieldmodel.cpp.
      
  | 
  override | 
Definition at line 254 of file qgsfieldmodel.cpp.
| void QgsFieldModel::setAllowEmptyFieldName | ( | bool | allowEmpty | ) | 
Sets whether an optional empty field ("not set") option is present in the model.
Definition at line 195 of file qgsfieldmodel.cpp.
| void QgsFieldModel::setAllowExpression | ( | bool | allowExpression | ) | 
Sets whether custom expressions are accepted and displayed in the model.
Definition at line 178 of file qgsfieldmodel.cpp.
| void QgsFieldModel::setExpression | ( | const QString & | expression | ) | 
Sets a single expression to be added after the fields at the end of the model.
Definition at line 215 of file qgsfieldmodel.cpp.
| void QgsFieldModel::setFields | ( | const QgsFields & | fields | ) | 
Manually sets the fields to use for the model.
This method should only be used when the model ISN'T associated with a layer() and needs to show the fields from an arbitrary field collection instead. Calling setFields() will automatically clear any existing layer().
Definition at line 518 of file qgsfieldmodel.cpp.
      
  | 
  slot | 
Set the layer from which fields are displayed.
Definition at line 80 of file qgsfieldmodel.cpp.
      
  | 
  protectedvirtualslot | 
Called when the model must be updated.
Definition at line 105 of file qgsfieldmodel.cpp.
      
  | 
  protected | 
Definition at line 201 of file qgsfieldmodel.h.
      
  | 
  protected | 
Definition at line 200 of file qgsfieldmodel.h.
      
  | 
  protected | 
Definition at line 197 of file qgsfieldmodel.h.
      
  | 
  protected | 
Definition at line 196 of file qgsfieldmodel.h.
      
  | 
  protected | 
Definition at line 199 of file qgsfieldmodel.h.
      
  | 
  readwrite | 
Definition at line 43 of file qgsfieldmodel.h.
      
  | 
  readwrite | 
Definition at line 42 of file qgsfieldmodel.h.
      
  | 
  readwrite | 
Definition at line 44 of file qgsfieldmodel.h.