23#include <QSharedDataPointer>
28using namespace Qt::StringLiterals;
90 QMetaType::Type
type = QMetaType::Type::UnknownType,
94 const QString &
comment = QString(),
116 const QString &
typeName = QString(),
119 const QString &
comment = QString(),
424 PyObject *sipParseErr = NULL;
431 if ( sipParseArgs( &sipParseErr, sipArgs,
"BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant, &a0, &a0State ) )
434 QString errorMessage;
436 Py_BEGIN_ALLOW_THREADS
445 sipReleaseType( a0, sipType_QVariant, a0State );
446 sipRaiseUnknownException();
454 PyErr_SetString( PyExc_ValueError,
455 QString(
"Value could not be converted to field type %1: %2" ).arg( QMetaType::typeName( sipCpp->
type() ), errorMessage ).toUtf8().constData() );
460 PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
461 sipReleaseType( a0, sipType_QVariant, a0State );
468 sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
478 operator QVariant()
const;
485 void setEditorWidgetSetup(
const QgsEditorWidgetSetup &v )
SIP_HOLDGIL;
495 QgsEditorWidgetSetup editorWidgetSetup() const
SIP_HOLDGIL;
519 Qgis::FieldDomainSplitPolicy splitPolicy() const
SIP_HOLDGIL;
529 void setSplitPolicy( Qgis::FieldDomainSplitPolicy policy )
SIP_HOLDGIL;
539 Qgis::FieldDuplicatePolicy duplicatePolicy() const
SIP_HOLDGIL;
549 void setDuplicatePolicy( Qgis::FieldDuplicatePolicy policy )
SIP_HOLDGIL;
559 Qgis::FieldDomainMergePolicy mergePolicy() const
SIP_HOLDGIL;
569 void setMergePolicy( Qgis::FieldDomainMergePolicy policy )
SIP_HOLDGIL;
572 SIP_PYOBJECT __repr__();
574 QString str = u
"<QgsField: %1 (%2)>"_s.arg( sipCpp->
name() ).arg( sipCpp->
typeName() );
575 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
585 QSharedDataPointer<QgsFieldPrivate> d;
Provides global constants and enumerations for use throughout the application.
Provides a container for managing client side default values for fields.
Stores information about constraints which may be present on a field.
Encapsulate a field in an attribute table or data source.
QString typeName() const
Gets the field type.
void setConstraints(const QgsFieldConstraints &constraints)
Sets constraints which are present for the field.
void setAlias(const QString &alias)
Sets the alias for the field (the friendly displayed name of the field ).
QString displayString(const QVariant &v) const
Formats string for display.
void setPrecision(int precision)
Set the field precision.
QString displayNameWithAlias() const
Returns the name to use when displaying this field and adds the alias in parenthesis if it is defined...
QgsField(const QString &name=QString(), QMetaType::Type type=QMetaType::Type::UnknownType, const QString &typeName=QString(), int len=0, int prec=0, const QString &comment=QString(), QMetaType::Type subType=QMetaType::Type::UnknownType)
Constructor.
bool convertCompatible(QVariant &v, QString *errorMessage=nullptr) const
Converts the provided variant to a compatible format.
void setSubType(QMetaType::Type subType)
If the field is a collection, set its element's type.
void setName(const QString &name)
Set the field name.
void setComment(const QString &comment)
Set the field comment.
void setType(QMetaType::Type type)
Set variant type.
QString displayType(bool showConstraints=false) const
Returns the type to use when displaying this field, including the length and precision of the datatyp...
void setConfigurationFlags(Qgis::FieldConfigurationFlags flags)
Sets the Flags for the field (searchable, …).
void setLength(int len)
Set the field length.
QString displayName() const
Returns the name to use when displaying this field.
void setDefaultValueDefinition(const QgsDefaultValue &defaultValueDefinition)
Sets an expression to use when calculating the default value for the field.
QString friendlyTypeString() const
Returns a user friendly, translated representation of the field type.
void setReadOnly(bool readOnly)
Make field read-only if readOnly is set to true.
QMap< int, QVariant > metadata() const
Returns the map of field metadata.
static QString readableConfigurationFlag(Qgis::FieldConfigurationFlag flag)
Returns the readable and translated value of the configuration flag.
Qgis::FieldConfigurationFlags configurationFlags
QMetaType::Type subType() const
If the field is a collection, gets its element's type.
static constexpr int MAX_WKT_LENGTH
QgsDefaultValue defaultValueDefinition
void setMetadata(const QMap< int, QVariant > metadata)
Sets the map of field metadata.
QgsFieldConstraints constraints
void setTypeName(const QString &typeName)
Set the field type.
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
QList< int > QgsAttributeList
CORE_EXPORT QDataStream & operator>>(QDataStream &in, QgsField &field)
Reads a field from stream in into field. QGIS version compatibility is not guaranteed.
CORE_EXPORT QDataStream & operator<<(QDataStream &out, const QgsField &field)
Writes the field to stream out. QGIS version compatibility is not guaranteed.