QGIS API Documentation 4.1.0-Master (009143bf4b4)
Loading...
Searching...
No Matches
QgsFieldCalculator Class Reference

A dialog that provides calculation of new fields using existing fields, values and a set of operators. More...

#include <qgsfieldcalculator.h>

Inheritance diagram for QgsFieldCalculator:

Public Slots

void accept () override

Public Member Functions

 QgsFieldCalculator (QgsVectorLayer *vl, QWidget *parent=nullptr, int fieldIndex=-1)
 Constructor for QgsFieldCalculator, with the specified parent widget.
int changedAttributeId () const
 Returns the field index of the field for which new attribute values were calculated.

Friends

class TestQgsFieldCalculator

Detailed Description

A dialog that provides calculation of new fields using existing fields, values and a set of operators.

Sample usage of the QgsFieldCalculator class:

uri = "point?crs=epsg:4326&field=id:integer"
layer = QgsVectorLayer(uri, "Scratch point layer", "memory")
layer.startEditing()
dialog = QgsFieldCalculator(layer)
dialog.exec()
A dialog that provides calculation of new fields using existing fields, values and a set of operators...
Represents a vector layer which manages a vector based dataset.

Definition at line 44 of file qgsfieldcalculator.h.

Constructor & Destructor Documentation

◆ QgsFieldCalculator()

QgsFieldCalculator::QgsFieldCalculator ( QgsVectorLayer * vl,
QWidget * parent = nullptr,
int fieldIndex = -1 )

Constructor for QgsFieldCalculator, with the specified parent widget.

The target layer must be specified using the vl argument.

Since QGIS 4.2, the optional fieldIndex argument can be used to automatically select the existing field with the specified index in the dialog.

Definition at line 51 of file qgsfieldcalculator.cpp.

Member Function Documentation

◆ accept

void QgsFieldCalculator::accept ( )
overrideslot

Definition at line 180 of file qgsfieldcalculator.cpp.

◆ changedAttributeId()

int QgsFieldCalculator::changedAttributeId ( ) const
inline

Returns the field index of the field for which new attribute values were calculated.

Returns
The field index if attribute values were calculated or -1, e.g. in case of geometry changes.

Definition at line 63 of file qgsfieldcalculator.h.

◆ TestQgsFieldCalculator

friend class TestQgsFieldCalculator
friend

Definition at line 105 of file qgsfieldcalculator.h.


The documentation for this class was generated from the following files: