Eneboo - Documentación para desarrolladores
Métodos públicos
Referencia de la Clase QSqlField

The QSqlField class manipulates the fields in SQL database tables and views. Más...

#include <qsqlfield.h>

Lista de todos los miembros.

Métodos públicos

 QSqlField (const QString &fieldName=QString::null, QVariant::Type type=QVariant::Invalid)
 QSqlField (const QSqlField &other)
QSqlFieldoperator= (const QSqlField &other)
bool operator== (const QSqlField &other) const
virtual ~QSqlField ()
virtual void setValue (const QVariant &value)
virtual QVariant value () const
virtual void setName (const QString &name)
QString name () const
virtual void setNull ()
bool isNull () const
virtual void setReadOnly (bool readOnly)
bool isReadOnly () const
void clear (bool nullify=TRUE)
QVariant::Type type () const
 QSqlField (const QString &fieldName=QString::null, QVariant::Type type=QVariant::Invalid)
 QSqlField (const QSqlField &other)
QSqlFieldoperator= (const QSqlField &other)
bool operator== (const QSqlField &other) const
virtual ~QSqlField ()
virtual void setValue (const QVariant &value)
virtual QVariant value () const
virtual void setName (const QString &name)
QString name () const
virtual void setNull ()
bool isNull () const
virtual void setReadOnly (bool readOnly)
bool isReadOnly () const
void clear (bool nullify=TRUE)
QVariant::Type type () const

Descripción detallada

The QSqlField class manipulates the fields in SQL database tables and views.

sql

QSqlField represents the characteristics of a single column in a database table or view, such as the data type and column name. A field also contains the value of the database column, which can be viewed or changed.

Field data values are stored as QVariants. Using an incompatible type is not permitted. For example:

    QSqlField f( "myfield", QVariant::Int );
    f.setValue( QPixmap() );  // will not work

However, the field will attempt to cast certain data types to the field data type where possible:

    QSqlField f( "myfield", QVariant::Int );
    f.setValue( QString("123") ); // casts QString to int

QSqlField objects are rarely created explicitly in application code. They are usually accessed indirectly through QSqlRecord or QSqlCursor which already contain a list of fields. For example:

    QSqlCursor cur( "Employee" );        // create cursor using the 'Employee' table
    QSqlField* f = cur.field( "name" );  // use the 'name' field
    f->setValue( "Dave" );               // set field value
    ...

In practice we rarely need to extract a pointer to a field at all. The previous example would normally be written:

    QSqlCursor cur( "Employee" );
    cur.setValue( "name", "Dave" );
    ...

Documentación del constructor y destructor

QSqlField::QSqlField ( const QString fieldName = QString::null,
QVariant::Type  type = QVariant::Invalid 
)

Constructs an empty field called fieldName of type type.

QSqlField::QSqlField ( const QSqlField other)

Constructs a copy of other.

QSqlField::~QSqlField ( ) [virtual]

Destroys the object and frees any allocated resources.

QSqlField::QSqlField ( const QString fieldName = QString::null,
QVariant::Type  type = QVariant::Invalid 
)
QSqlField::QSqlField ( const QSqlField other)
virtual QSqlField::~QSqlField ( ) [virtual]

Documentación de las funciones miembro

void QSqlField::clear ( bool  nullify = TRUE)

Clears the value of the field. If the field is read-only, nothing happens. If nullify is TRUE (the default), the field is set to NULL.

void QSqlField::clear ( bool  nullify = TRUE)
bool QSqlField::isNull ( ) const [inline]

Returns TRUE if the field is currently NULL; otherwise returns FALSE.

bool QSqlField::isNull ( ) const
bool QSqlField::isReadOnly ( ) const [inline]

Returns TRUE if the field's value is read only; otherwise returns FALSE.

bool QSqlField::isReadOnly ( ) const
QString QSqlField::name ( ) const
QString QSqlField::name ( ) const [inline]

Returns the name of the field.

QSqlField & QSqlField::operator= ( const QSqlField other)

Sets the field equal to other.

QSqlField& QSqlField::operator= ( const QSqlField other)
bool QSqlField::operator== ( const QSqlField other) const

Returns TRUE if the field is equal to other; otherwise returns FALSE. Fields are considered equal when the following field properties are the same:

name() isNull() value() isReadOnly()

bool QSqlField::operator== ( const QSqlField other) const
virtual void QSqlField::setName ( const QString name) [virtual]
void QSqlField::setName ( const QString name) [virtual]

Sets the name of the field to name.

virtual void QSqlField::setNull ( ) [virtual]
void QSqlField::setNull ( ) [virtual]

Sets the field to NULL and clears the value using clear(). If the field is read-only, nothing happens.

Ver también:
isReadOnly() clear()
void QSqlField::setReadOnly ( bool  readOnly) [virtual]

Sets the read only flag of the field's value to readOnly.

Ver también:
setValue()
virtual void QSqlField::setReadOnly ( bool  readOnly) [virtual]
virtual void QSqlField::setValue ( const QVariant value) [virtual]
void QSqlField::setValue ( const QVariant value) [virtual]

Sets the value of the field to value. If the field is read-only (isReadOnly() returns TRUE), nothing happens. If the data type of value differs from the field's current data type, an attempt is made to cast it to the proper type. This preserves the data type of the field in the case of assignment, e.g. a QString to an integer data type. For example:

    QSqlCursor cur( "Employee" );                 // 'Employee' table
    QSqlField* f = cur.field( "student_count" );  // an integer field
    ...
    f->setValue( myLineEdit->text() );            // cast the line edit text to an integer
Ver también:
isReadOnly()
QVariant::Type QSqlField::type ( ) const [inline]

Returns the field's type as stored in the database. Note that the actual value might have a different type, Numerical values that are too large to store in a long int or double are usually stored as strings to prevent precision loss.

QVariant::Type QSqlField::type ( ) const
virtual QVariant QSqlField::value ( ) const [virtual]
QVariant QSqlField::value ( ) const [inline, virtual]

Returns the value of the field as a QVariant.


La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'