56 Q_PROPERTY(
bool isNumeric READ isNumeric )
57 Q_PROPERTY(
bool isDateOrTime READ isDateOrTime )
58 Q_PROPERTY(
int length READ length WRITE setLength )
60 Q_PROPERTY( QVariant::Type type READ type WRITE setType )
61 Q_PROPERTY( QString comment READ comment WRITE setComment )
62 Q_PROPERTY( QString name READ name WRITE setName )
63 Q_PROPERTY( QString alias READ alias WRITE setAlias )
64 Q_PROPERTY(
QgsDefaultValue defaultValueDefinition READ defaultValueDefinition WRITE setDefaultValueDefinition )
66 Q_PROPERTY(
Qgis::FieldConfigurationFlags configurationFlags READ configurationFlags WRITE setConfigurationFlags )
67 Q_PROPERTY(
bool isReadOnly READ isReadOnly WRITE setReadOnly )
86 QgsField( const QString &name = QString(),
87 QVariant::Type type = QVariant::Invalid,
91 const QString &comment = QString(),
92 QVariant::Type subType = QVariant::Invalid );
106 bool operator==( const
QgsField &other ) const;
107 bool operator!=( const
QgsField &other ) const;
114 QString name() const;
123 QString displayName() const;
136 QString displayNameWithAlias() const;
148 QString displayType(
bool showConstraints = false ) const;
160 QString friendlyTypeString() const;
163 QVariant::Type type() const;
171 QVariant::Type subType() const;
196 QString comment() const;
206 QMap<
int, QVariant > metadata() const;
214 QVariant metadata(
Qgis::FieldMetadataProperty property ) const
SIP_SKIP;
222 QVariant metadata(
int property ) const;
232 void setMetadata( const QMap<
int, QVariant > metadata );
240 void setMetadata(
Qgis::FieldMetadataProperty property, const QVariant &value )
SIP_SKIP;
248 void setMetadata(
int property, const QVariant &value );
256 bool isNumeric() const;
263 bool isDateOrTime() const;
269 void setName( const QString &name );
274 void setType( QVariant::Type type );
282 void setSubType( QVariant::Type subType );
288 void setTypeName( const QString &
typeName );
294 void setLength(
int len );
305 void setComment( const QString &comment );
323 void setDefaultValueDefinition( const
QgsDefaultValue &defaultValueDefinition );
345 QString alias() const;
353 void setAlias( const QString &alias );
360 Qgis::FieldConfigurationFlags configurationFlags() const;
367 void setConfigurationFlags(
Qgis::FieldConfigurationFlags flags );
370 QString displayString( const QVariant &v ) const;
376 static QString readableConfigurationFlag(
Qgis::FieldConfigurationFlag flag );
388 bool convertCompatible( QVariant &v, QString *errorMessage =
nullptr )
const;
398 bool convertCompatible( QVariant &v )
const;
400 PyObject *sipParseErr = NULL;
407 if ( sipParseArgs( &sipParseErr, sipArgs,
"BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant, &a0, &a0State ) )
410 QString errorMessage;
412 Py_BEGIN_ALLOW_THREADS
421 sipReleaseType( a0, sipType_QVariant, a0State );
422 sipRaiseUnknownException();
430 PyErr_SetString( PyExc_ValueError,
431 QString(
"Value could not be converted to field type %1: %2" ).arg( QMetaType::typeName( sipCpp->
type() ), errorMessage ).toUtf8().constData() );
436 PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
437 sipReleaseType( a0, sipType_QVariant, a0State );
444 sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
454 operator QVariant()
const
456 return QVariant::fromValue( *
this );
481 void setReadOnly(
bool readOnly );
488 bool isReadOnly()
const;
511 SIP_PYOBJECT __repr__();
513 QString
str = QStringLiteral(
"<QgsField: %1 (%2)>" ).arg( sipCpp->
name() ).arg( sipCpp->
typeName() );
514 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
519 static constexpr int MAX_WKT_LENGTH = 999;
524 QSharedDataPointer<QgsFieldPrivate> d;