1QSqlField(3qt)                                                  QSqlField(3qt)
2
3
4

NAME

6       QSqlField - Manipulates the fields in SQL database tables and views
7

SYNOPSIS

9       #include <qsqlfield.h>
10
11   Public Members
12       QSqlField ( const QString & fieldName = QString::null, QVariant::Type
13           type = QVariant::Invalid )
14       QSqlField ( const QSqlField & other )
15       QSqlField & operator= ( const QSqlField & other )
16       bool operator== ( const QSqlField & other ) const
17       virtual ~QSqlField ()
18       virtual void setValue ( const QVariant & value )
19       virtual QVariant value () const
20       virtual void setName ( const QString & name )
21       QString name () const
22       virtual void setNull ()
23       bool isNull () const
24       virtual void setReadOnly ( bool readOnly )
25       bool isReadOnly () const
26       void clear ( bool nullify = TRUE )
27       QVariant::Type type () const
28

DESCRIPTION

30       The QSqlField class manipulates the fields in SQL database tables and
31       views.
32
33       QSqlField represents the characteristics of a single column in a
34       database table or view, such as the data type and column name. A field
35       also contains the value of the database column, which can be viewed or
36       changed.
37
38       Field data values are stored as QVariants. Using an incompatible type
39       is not permitted. For example:
40
41           QSqlField f( "myfield", QVariant::Int );
42           f.setValue( QPixmap() );  // will not work
43
44       However, the field will attempt to cast certain data types to the field
45       data type where possible:
46
47           QSqlField f( "myfield", QVariant::Int );
48           f.setValue( QString("123") ); // casts QString to int
49
50       QSqlField objects are rarely created explicitly in application code.
51       They are usually accessed indirectly through QSqlRecord or QSqlCursor
52       which already contain a list of fields. For example:
53
54           QSqlCursor cur( "Employee" );        // create cursor using the 'Employee' table
55           QSqlField* f = cur.field( "name" );  // use the 'name' field
56           f->setValue( "Dave" );               // set field value
57           ...
58
59       In practice we rarely need to extract a pointer to a field at all. The
60       previous example would normally be written:
61
62           QSqlCursor cur( "Employee" );
63           cur.setValue( "name", "Dave" );
64           ...
65
66       See also Database Classes.
67

MEMBER FUNCTION DOCUMENTATION

QSqlField::QSqlField ( const QString & fieldName = QString::null,

70       QVariant::Type type = QVariant::Invalid )
71       Constructs an empty field called fieldName of type type.
72

QSqlField::QSqlField ( const QSqlField & other )

74       Constructs a copy of other.
75

QSqlField::~QSqlField () [virtual]

77       Destroys the object and frees any allocated resources.
78

void QSqlField::clear ( bool nullify = TRUE )

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

bool QSqlField::isNull () const

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

bool QSqlField::isReadOnly () const

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

QString QSqlField::name () const

91       Returns the name of the field.
92
93       Example: sql/overview/table4/main.cpp.
94

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

96       Sets the field equal to other.
97

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

99       Returns TRUE if the field is equal to other; otherwise returns FALSE.
100       Fields are considered equal when the following field properties are the
101       same:
102
103       name()
104
105       isNull()
106
107       value()
108
109       isReadOnly()
110

void QSqlField::setName ( const QString & name ) [virtual]

112       Sets the name of the field to name.
113

void QSqlField::setNull () [virtual]

115       Sets the field to NULL and clears the value using clear(). If the field
116       is read-only, nothing happens.
117
118       See also isReadOnly() and clear().
119

void QSqlField::setReadOnly ( bool readOnly ) [virtual]

121       Sets the read only flag of the field's value to readOnly.
122
123       See also setValue().
124

void QSqlField::setValue ( const QVariant & value ) [virtual]

126       Sets the value of the field to value. If the field is read-only
127       (isReadOnly() returns TRUE), nothing happens. If the data type of value
128       differs from the field's current data type, an attempt is made to cast
129       it to the proper type. This preserves the data type of the field in the
130       case of assignment, e.g. a QString to an integer data type. For
131       example:
132
133           QSqlCursor cur( "Employee" );                 // 'Employee' table
134           QSqlField* f = cur.field( "student_count" );  // an integer field
135           ...
136           f->setValue( myLineEdit->text() );            // cast the line edit text to an integer
137
138       See also isReadOnly().
139

QVariant::Type QSqlField::type () const

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

QVariant QSqlField::value () const [virtual]

147       Returns the value of the field as a QVariant.
148
149       Example: sql/overview/table4/main.cpp.
150
151

SEE ALSO

153       http://doc.trolltech.com/qsqlfield.html
154       http://www.trolltech.com/faq/tech.html
155
157       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
158       license file included in the distribution for a complete license
159       statement.
160

AUTHOR

162       Generated automatically from the source code.
163

BUGS

165       If you find a bug in Qt, please report it as described in
166       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
167       help you. Thank you.
168
169       The definitive Qt documentation is provided in HTML format; it is
170       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
171       web browser. This man page is provided as a convenience for those users
172       who prefer man pages, although this format is not officially supported
173       by Trolltech.
174
175       If you find errors in this manual page, please report them to qt-
176       bugs@trolltech.com.  Please include the name of the manual page
177       (qsqlfield.3qt) and the Qt version (3.3.8).
178
179
180
181Trolltech AS                    2 February 2007                 QSqlField(3qt)
Impressum