You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
200 lines
6.6 KiB
200 lines
6.6 KiB
'\" t
|
|
.TH TQSqlField 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
|
|
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
|
|
.\" license file included in the distribution for a complete license
|
|
.\" statement.
|
|
.\"
|
|
.ad l
|
|
.nh
|
|
.SH NAME
|
|
TQSqlField \- Manipulates the fields in SQL database tables and views
|
|
.SH SYNOPSIS
|
|
\fC#include <tqsqlfield.h>\fR
|
|
.PP
|
|
.SS "Public Members"
|
|
.in +1c
|
|
.ti -1c
|
|
.BI "\fBTQSqlField\fR ( const TQString & fieldName = TQString::null, TQVariant::Type type = TQVariant::Invalid )"
|
|
.br
|
|
.ti -1c
|
|
.BI "\fBTQSqlField\fR ( const TQSqlField & other )"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQSqlField & \fBoperator=\fR ( const TQSqlField & other )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBoperator==\fR ( const TQSqlField & other ) const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual \fB~TQSqlField\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetValue\fR ( const TQVariant & value )"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual TQVariant \fBvalue\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetName\fR ( const TQString & name )"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQString \fBname\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetNull\fR ()"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBisNull\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "virtual void \fBsetReadOnly\fR ( bool readOnly )"
|
|
.br
|
|
.ti -1c
|
|
.BI "bool \fBisReadOnly\fR () const"
|
|
.br
|
|
.ti -1c
|
|
.BI "void \fBclear\fR ( bool nullify = TRUE )"
|
|
.br
|
|
.ti -1c
|
|
.BI "TQVariant::Type \fBtype\fR () const"
|
|
.br
|
|
.in -1c
|
|
.SH DESCRIPTION
|
|
The TQSqlField class manipulates the fields in SQL database tables and views.
|
|
.PP
|
|
TQSqlField 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.
|
|
.PP
|
|
Field data values are stored as TQVariants. Using an incompatible type is not permitted. For example:
|
|
.PP
|
|
.nf
|
|
.br
|
|
TQSqlField f( "myfield", TQVariant::Int );
|
|
.br
|
|
f.setValue( TQPixmap() ); // will not work
|
|
.br
|
|
.fi
|
|
.PP
|
|
However, the field will attempt to cast certain data types to the field data type where possible:
|
|
.PP
|
|
.nf
|
|
.br
|
|
TQSqlField f( "myfield", TQVariant::Int );
|
|
.br
|
|
f.setValue( TQString("123") ); // casts TQString to int
|
|
.br
|
|
.fi
|
|
.PP
|
|
TQSqlField objects are rarely created explicitly in application code. They are usually accessed indirectly through TQSqlRecord or TQSqlCursor which already contain a list of fields. For example:
|
|
.PP
|
|
.nf
|
|
.br
|
|
TQSqlCursor cur( "Employee" ); // create cursor using the 'Employee' table
|
|
.br
|
|
TQSqlField* f = cur.field( "name" ); // use the 'name' field
|
|
.br
|
|
f->setValue( "Dave" ); // set field value
|
|
.br
|
|
...
|
|
.br
|
|
.fi
|
|
.PP
|
|
In practice we rarely need to extract a pointer to a field at all. The previous example would normally be written:
|
|
.PP
|
|
.nf
|
|
.br
|
|
TQSqlCursor cur( "Employee" );
|
|
.br
|
|
cur.setValue( "name", "Dave" );
|
|
.br
|
|
...
|
|
.br
|
|
.fi
|
|
.PP
|
|
See also Database Classes.
|
|
.SH MEMBER FUNCTION DOCUMENTATION
|
|
.SH "TQSqlField::TQSqlField ( const TQString & fieldName = TQString::null, TQVariant::Type type = TQVariant::Invalid )"
|
|
Constructs an empty field called \fIfieldName\fR of type \fItype\fR.
|
|
.SH "TQSqlField::TQSqlField ( const TQSqlField & other )"
|
|
Constructs a copy of \fIother\fR.
|
|
.SH "TQSqlField::~TQSqlField ()\fC [virtual]\fR"
|
|
Destroys the object and frees any allocated resources.
|
|
.SH "void TQSqlField::clear ( bool nullify = TRUE )"
|
|
Clears the value of the field. If the field is read-only, nothing happens. If \fInullify\fR is TRUE (the default), the field is set to NULL.
|
|
.SH "bool TQSqlField::isNull () const"
|
|
Returns TRUE if the field is currently NULL; otherwise returns FALSE.
|
|
.SH "bool TQSqlField::isReadOnly () const"
|
|
Returns TRUE if the field's value is read only; otherwise returns FALSE.
|
|
.SH "TQString TQSqlField::name () const"
|
|
Returns the name of the field.
|
|
.PP
|
|
Example: sql/overview/table4/main.cpp.
|
|
.SH "TQSqlField & TQSqlField::operator= ( const TQSqlField & other )"
|
|
Sets the field equal to \fIother\fR.
|
|
.SH "bool TQSqlField::operator== ( const TQSqlField & other ) const"
|
|
Returns TRUE if the field is equal to \fIother\fR; otherwise returns FALSE. Fields are considered equal when the following field properties are the same:
|
|
.TP
|
|
name()
|
|
.TP
|
|
isNull()
|
|
.TP
|
|
value()
|
|
.TP
|
|
isReadOnly()
|
|
.SH "void TQSqlField::setName ( const TQString & name )\fC [virtual]\fR"
|
|
Sets the name of the field to \fIname\fR.
|
|
.SH "void TQSqlField::setNull ()\fC [virtual]\fR"
|
|
Sets the field to NULL and clears the value using clear(). If the field is read-only, nothing happens.
|
|
.PP
|
|
See also isReadOnly() and clear().
|
|
.SH "void TQSqlField::setReadOnly ( bool readOnly )\fC [virtual]\fR"
|
|
Sets the read only flag of the field's value to \fIreadOnly\fR.
|
|
.PP
|
|
See also setValue().
|
|
.SH "void TQSqlField::setValue ( const TQVariant & value )\fC [virtual]\fR"
|
|
Sets the value of the field to \fIvalue\fR. If the field is read-only (isReadOnly() returns TRUE), nothing happens. If the data type of \fIvalue\fR 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 TQString to an integer data type. For example:
|
|
.PP
|
|
.nf
|
|
.br
|
|
TQSqlCursor cur( "Employee" ); // 'Employee' table
|
|
.br
|
|
TQSqlField* f = cur.field( "student_count" ); // an integer field
|
|
.br
|
|
...
|
|
.br
|
|
f->setValue( myLineEdit->text() ); // cast the line edit text to an integer
|
|
.br
|
|
.fi
|
|
.PP
|
|
See also isReadOnly().
|
|
.SH "TQVariant::Type TQSqlField::type () const"
|
|
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.
|
|
.SH "TQVariant TQSqlField::value () const\fC [virtual]\fR"
|
|
Returns the value of the field as a TQVariant.
|
|
.PP
|
|
Example: sql/overview/table4/main.cpp.
|
|
|
|
.SH "SEE ALSO"
|
|
.BR http://doc.trolltech.com/tqsqlfield.html
|
|
.BR http://www.trolltech.com/faq/tech.html
|
|
.SH COPYRIGHT
|
|
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
|
|
license file included in the distribution for a complete license
|
|
statement.
|
|
.SH AUTHOR
|
|
Generated automatically from the source code.
|
|
.SH BUGS
|
|
If you find a bug in Qt, please report it as described in
|
|
.BR http://doc.trolltech.com/bughowto.html .
|
|
Good bug reports help us to help you. Thank you.
|
|
.P
|
|
The definitive TQt documentation is provided in HTML format; it is
|
|
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
|
|
a web browser. This man page is provided as a convenience for those
|
|
users who prefer man pages, although this format is not officially
|
|
supported by Trolltech.
|
|
.P
|
|
If you find errors in this manual page, please report them to
|
|
.BR qt-bugs@trolltech.com .
|
|
Please include the name of the manual page (tqsqlfield.3qt) and the Qt
|
|
version (3.3.8).
|