QGIS API Documentation
2.12.0-Lyon
|
Encapsulate a field in an attribute table or data source. More...
#include <qgsfield.h>
Public Member Functions | |
QgsField (const QString &name=QString(), QVariant::Type type=QVariant::Invalid, const QString &typeName=QString(), int len=0, int prec=0, const QString &comment=QString()) | |
Constructor. More... | |
QgsField (const QgsField &other) | |
Copy constructor. More... | |
virtual | ~QgsField () |
Destructor. More... | |
const QString & | comment () const |
Returns the field comment. More... | |
bool | convertCompatible (QVariant &v) const |
Converts the provided variant to a compatible format. More... | |
QString | displayString (const QVariant &v) const |
Formats string for display. More... | |
int | length () const |
Gets the length of the field. More... | |
const QString & | name () const |
Gets the name of the field. More... | |
bool | operator!= (const QgsField &other) const |
QgsField & | operator= (const QgsField &other) |
Assignment operator. More... | |
bool | operator== (const QgsField &other) const |
int | precision () const |
Gets the precision of the field. More... | |
void | setComment (const QString &comment) |
Set the field comment. More... | |
void | setLength (int len) |
Set the field length. More... | |
void | setName (const QString &name) |
Set the field name. More... | |
void | setPrecision (int precision) |
Set the field precision. More... | |
void | setType (QVariant::Type type) |
Set variant type. More... | |
void | setTypeName (const QString &typeName) |
Set the field type. More... | |
QVariant::Type | type () const |
Gets variant type of the field as it will be retrieved from data source. More... | |
const QString & | typeName () const |
Gets the field type. More... | |
Encapsulate a field in an attribute table or data source.
QgsField stores metadata about an attribute field, including name, type length, and if applicable, precision.
Definition at line 40 of file qgsfield.h.
QgsField::QgsField | ( | const QString & | name = QString() , |
QVariant::Type | type = QVariant::Invalid , |
||
const QString & | typeName = QString() , |
||
int | len = 0 , |
||
int | prec = 0 , |
||
const QString & | comment = QString() |
||
) |
Constructor.
Constructs a new QgsField object.
name | Field name |
type | Field variant type, currently supported: String / Int / Double |
typeName | Field type (eg. char, varchar, text, int, serial, double). Field types are usually unique to the source and are stored exactly as returned from the data store. |
len | Field length |
prec | Field precision. Usually decimal places but may also be used in conjunction with other fields types (eg. variable character fields) |
comment | Comment for the field |
Definition at line 39 of file qgsfield.cpp.
QgsField::QgsField | ( | const QgsField & | other | ) |
Copy constructor.
Definition at line 45 of file qgsfield.cpp.
|
virtual |
Destructor.
Definition at line 58 of file qgsfield.cpp.
const QString & QgsField::comment | ( | ) | const |
Returns the field comment.
Definition at line 97 of file qgsfield.cpp.
bool QgsField::convertCompatible | ( | QVariant & | v | ) | const |
Converts the provided variant to a compatible format.
v | The value to convert |
Definition at line 145 of file qgsfield.cpp.
Formats string for display.
Definition at line 131 of file qgsfield.cpp.
int QgsField::length | ( | ) | const |
Gets the length of the field.
Definition at line 87 of file qgsfield.cpp.
const QString & QgsField::name | ( | ) | const |
Gets the name of the field.
Definition at line 72 of file qgsfield.cpp.
bool QgsField::operator!= | ( | const QgsField & | other | ) | const |
Definition at line 67 of file qgsfield.cpp.
Assignment operator.
Definition at line 51 of file qgsfield.cpp.
bool QgsField::operator== | ( | const QgsField & | other | ) | const |
Definition at line 62 of file qgsfield.cpp.
int QgsField::precision | ( | ) | const |
Gets the precision of the field.
Not all field types have a related precision.
Definition at line 92 of file qgsfield.cpp.
void QgsField::setComment | ( | const QString & | comment | ) |
Set the field comment.
Definition at line 126 of file qgsfield.cpp.
void QgsField::setLength | ( | int | len | ) |
Set the field length.
len | Length of the field |
Definition at line 117 of file qgsfield.cpp.
void QgsField::setName | ( | const QString & | name | ) |
void QgsField::setPrecision | ( | int | precision | ) |
Set the field precision.
precision | Precision of the field |
Definition at line 121 of file qgsfield.cpp.
void QgsField::setType | ( | QVariant::Type | type | ) |
Set variant type.
Definition at line 107 of file qgsfield.cpp.
void QgsField::setTypeName | ( | const QString & | typeName | ) |
QVariant::Type QgsField::type | ( | ) | const |
Gets variant type of the field as it will be retrieved from data source.
Definition at line 77 of file qgsfield.cpp.
const QString & QgsField::typeName | ( | ) | const |
Gets the field type.
Field types vary depending on the data source. Examples are char, int, double, blob, geometry, etc. The type is stored exactly as the data store reports it, with no attempt to standardize the value.
Definition at line 82 of file qgsfield.cpp.