QgsPropertyDefinition class

Definition for a property.

QgsPropertyDefinition defines the type of values allowed for a property, and handles descriptive names and help text for using the property. Definitions can use one of the predefined standard templates to simplify definition of commonly used property types, such as colors and blend modes.

Public types

enum DataType { DataTypeString = 0, DataTypeNumeric, DataTypeBoolean }
Valid data types required by property.
enum StandardPropertyTemplate { Boolean = 0, Integer, IntegerPositive, IntegerPositiveGreaterZero, Double, DoublePositive, Double0To1, Rotation, String, Opacity, RenderUnits, ColorWithAlpha, ColorNoAlpha, PenJoinStyle, BlendMode, Point, Size, Size2D, LineStyle, StrokeWidth, FillStyle, CapStyle, HorizontalAnchor, VerticalAnchor, SvgPath, Offset, Custom = 3000 }
Predefined standard property templates.

Constructors, destructors, conversion operators

QgsPropertyDefinition() defaulted
Constructs an empty property.
QgsPropertyDefinition(const QString& name, const QString& description, StandardPropertyTemplate type, const QString& origin = QString(), const QString& comment = QString())
Constructor for QgsPropertyDefinition, using a standard property template.
QgsPropertyDefinition(const QString& name, DataType dataType, const QString& description, const QString& helpText, const QString& origin = QString(), const QString& comment = QString())
Constructor for custom QgsPropertyDefinitions.

Public functions

auto comment() const -> QString
Returns the comment of the property.
auto dataType() const -> DataType
Returns the allowable field/value data type for the property.
auto description() const -> QString
Descriptive name of the property.
auto helpText() const -> QString
Helper text for using the property, including a description of the valid values for the property.
auto name() const -> QString
Returns the name of the property.
auto origin() const -> QString
Returns the origin of the property.
void setComment(const QString& comment)
Sets comment of the property.
void setDataType(DataType type)
Sets the data type.
void setName(const QString& name)
Sets the name of the property.
void setOrigin(const QString& origin)
Sets the origin of the property.
auto standardTemplate() const -> StandardPropertyTemplate
Returns the property's standard template, if applicable.
auto supportsAssistant() const -> bool
Returns true if the property is of a type which is compatible with property override assistants.

Enum documentation

enum QgsPropertyDefinition::DataType

Valid data types required by property.

Enumerators
DataTypeString

Property requires a string value.

No numeric values are acceptable by the property. Use this for properties which require a string value such as 'dashed' which cannot be stored in a non-string field.

DataTypeNumeric

Property requires a numeric value.

Note that setting DataTypeNumeric as the required type means that the property also accepts string fields and inputs, as those may be convertible to a numeric value (Eg "1.0" -> 1.0)

DataTypeBoolean

Property requires a boolean value.

Note that setting DataTypeBoolean as the required type means that the property also accepts string and numeric fields, as those may be convertible to a boolean value (Eg "1.0" -> true)

enum QgsPropertyDefinition::StandardPropertyTemplate

Predefined standard property templates.

Enumerators
Boolean

Boolean value.

Integer

Integer value (including negative values)

IntegerPositive

Positive integer values (including 0)

IntegerPositiveGreaterZero

Non-zero positive integer values.

Double

Double value (including negative values)

DoublePositive

Positive double value (including 0)

Double0To1

Double value between 0-1 (inclusive)

Rotation

Rotation (value between 0-360 degrees)

String

Any string value.

Opacity

Opacity (0-100)

RenderUnits

Render units (eg mm/pixels/map units)

ColorWithAlpha

Color with alpha channel.

ColorNoAlpha

Color with no alpha channel.

PenJoinStyle

Pen join style.

BlendMode

Blend mode.

Point

2D point

Size

1D size (eg marker radius, or square marker height/width)

Size2D

2D size (width/height different)

LineStyle

Line style (eg solid/dashed)

StrokeWidth

Line stroke width.

FillStyle

Fill style (eg solid, lines)

CapStyle

Line cap style (eg round)

HorizontalAnchor

Horizontal anchor point.

VerticalAnchor

Vertical anchor point.

SvgPath

Path to an SVG file.

Offset

2D offset

Custom

Custom property types.

Function documentation

QgsPropertyDefinition::QgsPropertyDefinition(const QString& name, const QString& description, StandardPropertyTemplate type, const QString& origin = QString(), const QString& comment = QString())

Constructor for QgsPropertyDefinition, using a standard property template.

Parameters
name is used internally and should be a unique, alphanumeric string.
description can be any localised string describing what the property is used for.
type one of the predefined standard property template
origin The origin of the property
comment A free comment for the property

QgsPropertyDefinition::QgsPropertyDefinition(const QString& name, DataType dataType, const QString& description, const QString& helpText, const QString& origin = QString(), const QString& comment = QString())

Constructor for custom QgsPropertyDefinitions.

Parameters
name is used internally and should be a unique, alphanumeric string.
dataType the data type for the property
description can be any localised string describing what the property is used for.
helpText parameter should specify a descriptive string for users outlining the types of value acceptable by the property (eg 'dashed' or 'solid' for a line style property).
origin The origin of the property
comment A free comment for the property

QString QgsPropertyDefinition::name() const

Returns the name of the property.

This is used internally and should be a unique, alphanumeric string.

QString QgsPropertyDefinition::origin() const

Returns the origin of the property.

For example, a PAL property has an origin set to "labeling" while a diagram property has an origin set to "diagram".

void QgsPropertyDefinition::setOrigin(const QString& origin)

Sets the origin of the property.

For example, a PAL property has an origin set to "labeling" while a diagram property has an origin set to "diagram".

StandardPropertyTemplate QgsPropertyDefinition::standardTemplate() const

Returns the property's standard template, if applicable.

Non standard types will return the Custom template.