23#include <QSharedDataPointer>
88 QMetaType::Type
type = QMetaType::Type::UnknownType,
92 const QString &
comment = QString(),
114 const QString &
typeName = QString(),
117 const QString &
comment = QString(),
422 PyObject *sipParseErr = NULL;
429 if ( sipParseArgs( &sipParseErr, sipArgs,
"BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant, &a0, &a0State ) )
432 QString errorMessage;
434 Py_BEGIN_ALLOW_THREADS
443 sipReleaseType( a0, sipType_QVariant, a0State );
444 sipRaiseUnknownException();
452 PyErr_SetString( PyExc_ValueError,
453 QString(
"Value could not be converted to field type %1: %2" ).arg( QMetaType::typeName( sipCpp->
type() ), errorMessage ).toUtf8().constData() );
458 PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
459 sipReleaseType( a0, sipType_QVariant, a0State );
466 sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
476 operator QVariant()
const;
483 void setEditorWidgetSetup(
const QgsEditorWidgetSetup &v )
SIP_HOLDGIL;
493 QgsEditorWidgetSetup editorWidgetSetup() const
SIP_HOLDGIL;
517 Qgis::FieldDomainSplitPolicy splitPolicy() const
SIP_HOLDGIL;
527 void setSplitPolicy( Qgis::FieldDomainSplitPolicy policy )
SIP_HOLDGIL;
537 Qgis::FieldDuplicatePolicy duplicatePolicy() const
SIP_HOLDGIL;
547 void setDuplicatePolicy( Qgis::FieldDuplicatePolicy policy )
SIP_HOLDGIL;
557 Qgis::FieldDomainMergePolicy mergePolicy() const
SIP_HOLDGIL;
567 void setMergePolicy( Qgis::FieldDomainMergePolicy policy )
SIP_HOLDGIL;
570 SIP_PYOBJECT __repr__();
572 QString str = QStringLiteral(
"<QgsField: %1 (%2)>" ).arg( sipCpp->
name() ).arg( sipCpp->
typeName() );
573 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
583 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.