23#include <QSharedDataPointer>
28using namespace Qt::StringLiterals;
90 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 )
SIP_HOLDGIL;
112 const QString &
typeName = QString(),
115 const QString &
comment = QString(),
436 PyObject *sipParseErr = NULL;
443 if ( sipParseArgs( &sipParseErr, sipArgs,
"BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant, &a0, &a0State ) )
446 QString errorMessage;
448 Py_BEGIN_ALLOW_THREADS
457 sipReleaseType( a0, sipType_QVariant, a0State );
458 sipRaiseUnknownException();
466 PyErr_SetString( PyExc_ValueError,
467 QString(
"Value could not be converted to field type %1: %2" ).arg( QMetaType::typeName( sipCpp->
type() ), errorMessage ).toUtf8().constData() );
472 PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
473 sipReleaseType( a0, sipType_QVariant, a0State );
480 sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
491 operator QVariant()
const;
498 void setEditorWidgetSetup(
const QgsEditorWidgetSetup &v )
SIP_HOLDGIL;
508 QgsEditorWidgetSetup editorWidgetSetup() const
SIP_HOLDGIL;
532 Qgis::FieldDomainSplitPolicy splitPolicy() const
SIP_HOLDGIL;
542 void setSplitPolicy( Qgis::FieldDomainSplitPolicy policy )
SIP_HOLDGIL;
552 Qgis::FieldDuplicatePolicy duplicatePolicy() const
SIP_HOLDGIL;
562 void setDuplicatePolicy( Qgis::FieldDuplicatePolicy policy )
SIP_HOLDGIL;
572 Qgis::FieldDomainMergePolicy mergePolicy() const
SIP_HOLDGIL;
582 void setMergePolicy( Qgis::FieldDomainMergePolicy policy )
SIP_HOLDGIL;
586 SIP_PYOBJECT __repr__();
588 QString str = u
"<QgsField: %1 (%2)>"_s.arg( sipCpp->
name() ).arg( sipCpp->
typeName() );
589 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
600 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.
void setCustomComment(const QString &customComment)
Sets the custom comment for the field.
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.