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;
122 QString displayName() const;
135 QString displayNameWithAlias() const;
147 QString displayType(
bool showConstraints = false ) const;
159 QString friendlyTypeString() const;
162 QVariant::Type type() const;
169 QVariant::Type subType() const;
194 QString comment() const;
204 QMap<
int, QVariant > metadata() const;
212 QVariant metadata(
Qgis::FieldMetadataProperty property ) const
SIP_SKIP;
220 QVariant metadata(
int property ) const;
230 void setMetadata( const QMap<
int, QVariant > metadata );
238 void setMetadata(
Qgis::FieldMetadataProperty property, const QVariant &value )
SIP_SKIP;
246 void setMetadata(
int property, const QVariant &value );
253 bool isNumeric() const;
260 bool isDateOrTime() const;
266 void setName( const QString &name );
271 void setType( QVariant::Type type );
278 void setSubType( QVariant::Type subType );
284 void setTypeName( const QString &
typeName );
290 void setLength(
int len );
301 void setComment( const QString &comment );
317 void setDefaultValueDefinition( const
QgsDefaultValue &defaultValueDefinition );
336 QString alias() const;
343 void setAlias( const QString &alias );
350 Qgis::FieldConfigurationFlags configurationFlags() const;
357 void setConfigurationFlags(
Qgis::FieldConfigurationFlags flags );
360 QString displayString( const QVariant &v ) const;
366 static QString readableConfigurationFlag(
Qgis::FieldConfigurationFlag flag );
378 bool convertCompatible( QVariant &v, QString *errorMessage =
nullptr )
const;
388 bool convertCompatible( QVariant &v )
const;
390 PyObject *sipParseErr = NULL;
397 if ( sipParseArgs( &sipParseErr, sipArgs,
"BJ1", &sipSelf, sipType_QgsField, &sipCpp, sipType_QVariant, &a0, &a0State ) )
400 QString errorMessage;
402 Py_BEGIN_ALLOW_THREADS
411 sipReleaseType( a0, sipType_QVariant, a0State );
412 sipRaiseUnknownException();
420 PyErr_SetString( PyExc_ValueError,
421 QString(
"Value could not be converted to field type %1: %2" ).arg( QMetaType::typeName( sipCpp->
type() ), errorMessage ).toUtf8().constData() );
426 PyObject *res = sipConvertFromType( a0, sipType_QVariant, NULL );
427 sipReleaseType( a0, sipType_QVariant, a0State );
434 sipNoMethod( sipParseErr, sipName_QgsField, sipName_convertCompatible, doc_QgsField_convertCompatible );
444 operator QVariant()
const
446 return QVariant::fromValue( *
this );
471 void setReadOnly(
bool readOnly );
478 bool isReadOnly()
const;
501 SIP_PYOBJECT __repr__();
503 QString
str = QStringLiteral(
"<QgsField: %1 (%2)>" ).arg( sipCpp->
name() ).arg( sipCpp->
typeName() );
504 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
509 static constexpr int MAX_WKT_LENGTH = 999;
514 QSharedDataPointer<QgsFieldPrivate> d;