QgsAttributes class

A vector of attributes.

Mostly equal to QVector<QVariant>.

Constructors, destructors, conversion operators

QgsAttributes() defaulted
Constructor for QgsAttributes.
QgsAttributes(int size)
Create a new vector of attributes with the given size.
QgsAttributes(int size, const QVariant& v)
Constructs a vector with an initial size of size elements.
QgsAttributes(const QVector<QVariant>& v)
Copies another vector of attributes.

Public functions

auto operator==(const QgsAttributes& v) const -> bool
Compares two vectors of attributes.
auto toMap() const -> QgsAttributeMap
Returns a QgsAttributeMap of the attribute values.

Function documentation

QgsAttributes::QgsAttributes(int size)

Create a new vector of attributes with the given size.

Parameters
size Number of attributes

QgsAttributes::QgsAttributes(int size, const QVariant& v)

Constructs a vector with an initial size of size elements.

Parameters
size Number of elements
v Initial value

Each element is initialized with value.

QgsAttributes::QgsAttributes(const QVector<QVariant>& v)

Copies another vector of attributes.

Parameters
v Attributes to copy

bool QgsAttributes::operator==(const QgsAttributes& v) const

Compares two vectors of attributes.

Parameters
v The attributes to compare
Returns True if v is equal

They are considered equal if all their members contain the same value and NULL flag. This was introduced because the default Qt implementation of QVariant comparison does not handle NULL values for certain types (like int).

QgsAttributeMap QgsAttributes::toMap() const

Returns a QgsAttributeMap of the attribute values.

Null values are excluded from the map.