6
6
td.postheader { font-family: sans-serif }
7
7
tr.address { font-family: sans-serif }
8
8
body { background: #ffffff; color: black; }
9
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QSqlField Class Reference<br /><sup><sup>[<a href="qtsql.html">QtSql</a> module]</sup></sup></h1><p>The QSqlField class manipulates the fields in SQL database tables and views. <a href="#details">More...</a></p>
10
<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qsqlfield.html#RequiredStatus-enum">RequiredStatus</a></b> { Unknown, Optional, Required }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qsqlfield.html#QSqlField">__init__</a></b> (<i>self</i>, QString <i>fieldName</i> = QString(), QVariant.Type <i>type</i> = QVariant.Invalid)</li><li><div class="fn" /><b><a href="qsqlfield.html#QSqlField-2">__init__</a></b> (<i>self</i>, QSqlField)</li><li><div class="fn" /><b><a href="qsqlfield.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qsqlfield.html#defaultValue">defaultValue</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlfield.html#isAutoValue">isAutoValue</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlfield.html#isGenerated">isGenerated</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlfield.html#isNull">isNull</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlfield.html#isReadOnly">isReadOnly</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlfield.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qsqlfield.html#length">length</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsqlfield.html#name">name</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qsqlfield.html#precision">precision</a></b> (<i>self</i>)</li><li><div class="fn" />RequiredStatus <b><a href="qsqlfield.html#requiredStatus">requiredStatus</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsqlfield.html#setAutoValue">setAutoValue</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qsqlfield.html#setDefaultValue">setDefaultValue</a></b> (<i>self</i>, QVariant)</li><li><div class="fn" /><b><a href="qsqlfield.html#setGenerated">setGenerated</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qsqlfield.html#setLength">setLength</a></b> (<i>self</i>, int)</li><li><div class="fn" /><b><a href="qsqlfield.html#setName">setName</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qsqlfield.html#setPrecision">setPrecision</a></b> (<i>self</i>, int)</li><li><div class="fn" /><b><a href="qsqlfield.html#setReadOnly">setReadOnly</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qsqlfield.html#setRequired">setRequired</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a></b> (<i>self</i>, RequiredStatus)</li><li><div class="fn" /><b><a href="qsqlfield.html#setSqlType">setSqlType</a></b> (<i>self</i>, int)</li><li><div class="fn" /><b><a href="qsqlfield.html#setType">setType</a></b> (<i>self</i>, QVariant.Type)</li><li><div class="fn" /><b><a href="qsqlfield.html#setValue">setValue</a></b> (<i>self</i>, QVariant)</li><li><div class="fn" />QVariant.Type <b><a href="qsqlfield.html#type">type</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qsqlfield.html#typeID">typeID</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qsqlfield.html#value">value</a></b> (<i>self</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qsqlfield.html#__eq__">__eq__</a></b> (<i>self</i>, QSqlField)</li><li><div class="fn" />bool <b><a href="qsqlfield.html#__ne__">__ne__</a></b> (<i>self</i>, QSqlField)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QSqlField class manipulates the fields in SQL database tables and views.</p>
11
<p>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.</p>
12
<p>Field data values are stored as QVariants. Using an incompatible type is not permitted. For example:</p>
13
<pre> QSqlField field("age", QVariant.Int);
14
field.setValue(QPixmap()); <span class="comment">// WRONG</span></pre>
15
<p>However, the field will attempt to cast certain data types to the field data type where possible:</p>
16
<pre> QSqlField field("age", QVariant.Int);
17
field.setValue(QString("123")); <span class="comment">// casts QString to int</span></pre>
18
<p>QSqlField objects are rarely created explicitly in application code. They are usually accessed indirectly through <a href="qsqlrecord.html">QSqlRecord</a>s that already contain a list of fields. For example:</p>
19
<pre> QSqlQuery query;
9
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QSqlField Class Reference<br /><sup><sup>[<a href="qtsql.html">QtSql</a> module]</sup></sup></h1><p>The QSqlField class manipulates the fields in SQL database
10
tables and views. <a href="#details">More...</a></p>
12
<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qsqlfield.html#RequiredStatus-enum">RequiredStatus</a></b> { Unknown, Optional, Required }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qsqlfield.html#QSqlField">__init__</a></b> (<i>self</i>, QString <i>fieldName</i> = QString(), QVariant.Type <i>type</i> = QVariant.Invalid)</li><li><div class="fn" /><b><a href="qsqlfield.html#QSqlField-2">__init__</a></b> (<i>self</i>, QSqlField)</li><li><div class="fn" /><b><a href="qsqlfield.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qsqlfield.html#defaultValue">defaultValue</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlfield.html#isAutoValue">isAutoValue</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlfield.html#isGenerated">isGenerated</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlfield.html#isNull">isNull</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlfield.html#isReadOnly">isReadOnly</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qsqlfield.html#isValid">isValid</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qsqlfield.html#length">length</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qsqlfield.html#name">name</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qsqlfield.html#precision">precision</a></b> (<i>self</i>)</li><li><div class="fn" />RequiredStatus <b><a href="qsqlfield.html#requiredStatus">requiredStatus</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qsqlfield.html#setAutoValue">setAutoValue</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qsqlfield.html#setDefaultValue">setDefaultValue</a></b> (<i>self</i>, QVariant)</li><li><div class="fn" /><b><a href="qsqlfield.html#setGenerated">setGenerated</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qsqlfield.html#setLength">setLength</a></b> (<i>self</i>, int)</li><li><div class="fn" /><b><a href="qsqlfield.html#setName">setName</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qsqlfield.html#setPrecision">setPrecision</a></b> (<i>self</i>, int)</li><li><div class="fn" /><b><a href="qsqlfield.html#setReadOnly">setReadOnly</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qsqlfield.html#setRequired">setRequired</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a></b> (<i>self</i>, RequiredStatus)</li><li><div class="fn" /><b><a href="qsqlfield.html#setSqlType">setSqlType</a></b> (<i>self</i>, int)</li><li><div class="fn" /><b><a href="qsqlfield.html#setType">setType</a></b> (<i>self</i>, QVariant.Type)</li><li><div class="fn" /><b><a href="qsqlfield.html#setValue">setValue</a></b> (<i>self</i>, QVariant)</li><li><div class="fn" />QVariant.Type <b><a href="qsqlfield.html#type">type</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qsqlfield.html#typeID">typeID</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qsqlfield.html#value">value</a></b> (<i>self</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qsqlfield.html#__eq__">__eq__</a></b> (<i>self</i>, QSqlField)</li><li><div class="fn" />bool <b><a href="qsqlfield.html#__ne__">__ne__</a></b> (<i>self</i>, QSqlField)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QSqlField class manipulates the fields in SQL database
14
<p>QSqlField represents the characteristics of a single column in a
15
database table or view, such as the data type and column name. A
16
field also contains the value of the database column, which can be
17
viewed or changed.</p>
18
<p>Field data values are stored as <a href="qtwebkit-bridge.html#qvariants">QVariants</a>. Using an
19
incompatible type is not permitted. For example:</p>
20
<pre class="highlightedCode brush: cpp">
21
QSqlField field("age", QVariant.Int);
22
field.setValue(QPixmap()); <span class="comment">// WRONG</span>
24
<p>However, the field will attempt to cast certain data types to
25
the field data type where possible:</p>
26
<pre class="highlightedCode brush: cpp">
27
QSqlField field("age", QVariant.Int);
28
field.setValue(QString("123")); <span class="comment">// casts QString to int</span>
30
<p>QSqlField objects are rarely created explicitly in application
31
code. They are usually accessed indirectly through <a href="qsqlrecord.html">QSqlRecord</a>s that already contain a list of
32
fields. For example:</p>
33
<pre class="highlightedCode brush: cpp">
21
36
QSqlRecord record = query.record();
22
QSqlField field = record.field("country");</pre>
23
<p>A QSqlField object can provide some meta-data about the field, for example, its <a href="qsqlfield.html#name">name</a>(), variant <a href="qsqlfield.html#type">type</a>(), <a href="qsqlfield.html#length">length</a>(), <a href="qsqlfield.html#precision">precision</a>(), <a href="qsqlfield.html#defaultValue">defaultValue</a>(), typeID(), and its <a href="qsqlfield.html#requiredStatus">requiredStatus</a>(), <a href="qsqlfield.html#isGenerated">isGenerated</a>() and <a href="qsqlfield.html#isReadOnly">isReadOnly</a>(). The field's data can be checked to see if it <a href="qsqlfield.html#isNull">isNull</a>(), and its <a href="qsqlfield.html#value">value</a>() retrieved. When editing the data can be set with <a href="qsqlfield.html#setValue">setValue</a>() or set to NULL with <a href="qsqlfield.html#clear">clear</a>().</p>
24
<p>See also <a href="qsqlrecord.html">QSqlRecord</a>.</p>
37
QSqlField field = record.field("country");
39
<p>A QSqlField object can provide some meta-data about the field,
40
for example, its <a href="qsqlfield.html#name">name</a>(), variant
41
<a href="qsqlfield.html#type">type</a>(), <a href="qsqlfield.html#length">length</a>(), <a href="qsqlfield.html#precision">precision</a>(), <a href="qsqlfield.html#defaultValue">defaultValue</a>(), typeID(), and its
42
<a href="qsqlfield.html#requiredStatus">requiredStatus</a>(),
43
<a href="qsqlfield.html#isGenerated">isGenerated</a>() and <a href="qsqlfield.html#isReadOnly">isReadOnly</a>(). The field's data can
44
be checked to see if it <a href="qsqlfield.html#isNull">isNull</a>(), and its <a href="qsqlfield.html#value">value</a>() retrieved. When editing the data
45
can be set with <a href="qsqlfield.html#setValue">setValue</a>() or
46
set to NULL with <a href="qsqlfield.html#clear">clear</a>().</p>
25
47
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="RequiredStatus-enum" />QSqlField.RequiredStatus</h3><p>Specifies whether the field is required or optional.</p>
26
<p><table border="1" cellpadding="2" cellspacing="1" class="valuelist" width="100%">
27
<tr><th width="25%">Constant</th><th width="15%">Value</th><th width="60%">Description</th></tr>
28
<tr><td valign="top"><tt>QSqlField.Required</tt></td><td align="center" valign="top"><tt>1</tt></td><td valign="top">The field must be specified when inserting records.</td></tr>
29
<tr><td valign="top"><tt>QSqlField.Optional</tt></td><td align="center" valign="top"><tt>0</tt></td><td valign="top">The fields doesn't have to be specified when inserting records.</td></tr>
30
<tr><td valign="top"><tt>QSqlField.Unknown</tt></td><td align="center" valign="top"><tt>-1</tt></td><td valign="top">The database driver couldn't determine whether the field is required or optional.</td></tr>
48
<table class="valuelist">
53
<th class="tblConst">Constant</th>
54
<th class="tblval">Value</th>
55
<th class="tbldscr">Description</th>
58
<td class="topAlign"><tt>QSqlField.Required</tt></td>
59
<td class=" topAlign"><tt>1</tt></td>
60
<td class="topAlign">The field must be specified when inserting
64
<td class="topAlign"><tt>QSqlField.Optional</tt></td>
65
<td class=" topAlign"><tt>0</tt></td>
66
<td class="topAlign">The fields doesn't have to be specified when
67
inserting records.</td>
70
<td class="topAlign"><tt>QSqlField.Unknown</tt></td>
71
<td class=" topAlign"><tt>-1</tt></td>
72
<td class="topAlign">The database driver couldn't determine whether
73
the field is required or optional.</td>
32
76
<p>See also <a href="qsqlfield.html#requiredStatus">requiredStatus</a>().</p>
33
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QSqlField" />QSqlField.__init__ (<i>self</i>, QString <i>fieldName</i> = QString(), <a href="qvariant.html#Type-enum">QVariant.Type</a> <i>type</i> = QVariant.Invalid)</h3><p>Constructs an empty field called <i>fieldName</i> of variant type <i>type</i>.</p>
34
<p>See also <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>(), <a href="qsqlfield.html#setLength">setLength</a>(), <a href="qsqlfield.html#setPrecision">setPrecision</a>(), <a href="qsqlfield.html#setDefaultValue">setDefaultValue</a>(), <a href="qsqlfield.html#setGenerated">setGenerated</a>(), and <a href="qsqlfield.html#setReadOnly">setReadOnly</a>().</p>
77
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QSqlField" />QSqlField.__init__ (<i>self</i>, QString <i>fieldName</i> = QString(), <a href="qvariant.html#Type-enum">QVariant.Type</a> <i>type</i> = QVariant.Invalid)</h3><p>Constructs an empty field called <i>fieldName</i> of variant
79
<p>See also <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>(),
80
<a href="qsqlfield.html#setLength">setLength</a>(), <a href="qsqlfield.html#setPrecision">setPrecision</a>(), <a href="qsqlfield.html#setDefaultValue">setDefaultValue</a>(), <a href="qsqlfield.html#setGenerated">setGenerated</a>(), and <a href="qsqlfield.html#setReadOnly">setReadOnly</a>().</p>
35
83
<h3 class="fn"><a name="QSqlField-2" />QSqlField.__init__ (<i>self</i>, <a href="qsqlfield.html">QSqlField</a>)</h3><p>Constructs a copy of <i>other</i>.</p>
36
<a name="//apple_ref/cpp/instm/QSqlField/~QSqlField" />
37
<h3 class="fn"><a name="clear" />QSqlField.clear (<i>self</i>)</h3><p>Clears the value of the field and sets it to NULL. If the field is read-only, nothing happens.</p>
38
<p>See also <a href="qsqlfield.html#setValue">setValue</a>(), <a href="qsqlfield.html#isReadOnly">isReadOnly</a>(), and <a href="qsqlfield.html#requiredStatus">requiredStatus</a>().</p>
39
<a name="//apple_ref/cpp/instm/QSqlField/defaultValue" />
86
<h3 class="fn"><a name="clear" />QSqlField.clear (<i>self</i>)</h3><p>Clears the value of the field and sets it to NULL. If the field
87
is read-only, nothing happens.</p>
88
<p>See also <a href="qsqlfield.html#setValue">setValue</a>(),
89
<a href="qsqlfield.html#isReadOnly">isReadOnly</a>(), and <a href="qsqlfield.html#requiredStatus">requiredStatus</a>().</p>
40
92
<h3 class="fn"><a name="defaultValue" />QVariant QSqlField.defaultValue (<i>self</i>)</h3><p>Returns the field's default value (which may be NULL).</p>
41
93
<p>See also <a href="qsqlfield.html#setDefaultValue">setDefaultValue</a>(), <a href="qsqlfield.html#type">type</a>(), <a href="qsqlfield.html#requiredStatus">requiredStatus</a>(), <a href="qsqlfield.html#length">length</a>(), <a href="qsqlfield.html#precision">precision</a>(), and <a href="qsqlfield.html#isGenerated">isGenerated</a>().</p>
42
<a name="//apple_ref/cpp/instm/QSqlField/isAutoValue" />
43
<h3 class="fn"><a name="isAutoValue" />bool QSqlField.isAutoValue (<i>self</i>)</h3><p>Returns true if the value is auto-generated by the database, for example auto-increment primary key values.</p>
96
<h3 class="fn"><a name="isAutoValue" />bool QSqlField.isAutoValue (<i>self</i>)</h3><p>Returns true if the value is auto-generated by the database, for
97
example auto-increment primary key values.</p>
44
98
<p>See also <a href="qsqlfield.html#setAutoValue">setAutoValue</a>().</p>
45
<a name="//apple_ref/cpp/instm/QSqlField/isGenerated" />
46
<h3 class="fn"><a name="isGenerated" />bool QSqlField.isGenerated (<i>self</i>)</h3><p>Returns true if the field is generated; otherwise returns false.</p>
101
<h3 class="fn"><a name="isGenerated" />bool QSqlField.isGenerated (<i>self</i>)</h3><p>Returns true if the field is generated; otherwise returns
47
103
<p>See also <a href="qsqlfield.html#setGenerated">setGenerated</a>(), <a href="qsqlfield.html#type">type</a>(), <a href="qsqlfield.html#requiredStatus">requiredStatus</a>(), <a href="qsqlfield.html#length">length</a>(), <a href="qsqlfield.html#precision">precision</a>(), and <a href="qsqlfield.html#defaultValue">defaultValue</a>().</p>
48
<a name="//apple_ref/cpp/instm/QSqlField/isNull" />
49
<h3 class="fn"><a name="isNull" />bool QSqlField.isNull (<i>self</i>)</h3><p>Returns true if the field's value is NULL; otherwise returns false.</p>
106
<h3 class="fn"><a name="isNull" />bool QSqlField.isNull (<i>self</i>)</h3><p>Returns true if the field's value is NULL; otherwise returns
50
108
<p>See also <a href="qsqlfield.html#value">value</a>().</p>
51
<a name="//apple_ref/cpp/instm/QSqlField/isReadOnly" />
52
<h3 class="fn"><a name="isReadOnly" />bool QSqlField.isReadOnly (<i>self</i>)</h3><p>Returns true if the field's value is read-only; otherwise returns false.</p>
53
<p>See also <a href="qsqlfield.html#setReadOnly">setReadOnly</a>(), <a href="qsqlfield.html#type">type</a>(), <a href="qsqlfield.html#requiredStatus">requiredStatus</a>(), <a href="qsqlfield.html#length">length</a>(), <a href="qsqlfield.html#precision">precision</a>(), <a href="qsqlfield.html#defaultValue">defaultValue</a>(), and <a href="qsqlfield.html#isGenerated">isGenerated</a>().</p>
54
<a name="//apple_ref/cpp/instm/QSqlField/isValid" />
55
<h3 class="fn"><a name="isValid" />bool QSqlField.isValid (<i>self</i>)</h3><p>Returns true if the field's variant type is valid; otherwise returns false.</p>
56
<a name="//apple_ref/cpp/instm/QSqlField/length" />
111
<h3 class="fn"><a name="isReadOnly" />bool QSqlField.isReadOnly (<i>self</i>)</h3><p>Returns true if the field's value is read-only; otherwise
113
<p>See also <a href="qsqlfield.html#setReadOnly">setReadOnly</a>(),
114
<a href="qsqlfield.html#type">type</a>(), <a href="qsqlfield.html#requiredStatus">requiredStatus</a>(), <a href="qsqlfield.html#length">length</a>(), <a href="qsqlfield.html#precision">precision</a>(), <a href="qsqlfield.html#defaultValue">defaultValue</a>(), and <a href="qsqlfield.html#isGenerated">isGenerated</a>().</p>
117
<h3 class="fn"><a name="isValid" />bool QSqlField.isValid (<i>self</i>)</h3><p>Returns true if the field's variant type is valid; otherwise
57
121
<h3 class="fn"><a name="length" />int QSqlField.length (<i>self</i>)</h3><p>Returns the field's length.</p>
58
<p>If the returned value is negative, it means that the information is not available from the database.</p>
59
<p>See also <a href="qsqlfield.html#setLength">setLength</a>(), <a href="qsqlfield.html#type">type</a>(), <a href="qsqlfield.html#requiredStatus">requiredStatus</a>(), <a href="qsqlfield.html#precision">precision</a>(), <a href="qsqlfield.html#defaultValue">defaultValue</a>(), and <a href="qsqlfield.html#isGenerated">isGenerated</a>().</p>
60
<a name="//apple_ref/cpp/instm/QSqlField/name" />
122
<p>If the returned value is negative, it means that the information
123
is not available from the database.</p>
124
<p>See also <a href="qsqlfield.html#setLength">setLength</a>(),
125
<a href="qsqlfield.html#type">type</a>(), <a href="qsqlfield.html#requiredStatus">requiredStatus</a>(), <a href="qsqlfield.html#precision">precision</a>(), <a href="qsqlfield.html#defaultValue">defaultValue</a>(), and <a href="qsqlfield.html#isGenerated">isGenerated</a>().</p>
61
128
<h3 class="fn"><a name="name" />QString QSqlField.name (<i>self</i>)</h3><p>Returns the name of the field.</p>
62
129
<p>See also <a href="qsqlfield.html#setName">setName</a>().</p>
63
<a name="//apple_ref/cpp/instm/QSqlField/precision" />
64
<h3 class="fn"><a name="precision" />int QSqlField.precision (<i>self</i>)</h3><p>Returns the field's precision; this is only meaningful for numeric types.</p>
65
<p>If the returned value is negative, it means that the information is not available from the database.</p>
132
<h3 class="fn"><a name="precision" />int QSqlField.precision (<i>self</i>)</h3><p>Returns the field's precision; this is only meaningful for
134
<p>If the returned value is negative, it means that the information
135
is not available from the database.</p>
66
136
<p>See also <a href="qsqlfield.html#setPrecision">setPrecision</a>(), <a href="qsqlfield.html#type">type</a>(), <a href="qsqlfield.html#requiredStatus">requiredStatus</a>(), <a href="qsqlfield.html#length">length</a>(), <a href="qsqlfield.html#defaultValue">defaultValue</a>(), and <a href="qsqlfield.html#isGenerated">isGenerated</a>().</p>
67
<a name="//apple_ref/cpp/instm/QSqlField/requiredStatus" />
68
<h3 class="fn"><a name="requiredStatus" /><a href="qsqlfield.html#RequiredStatus-enum">RequiredStatus</a> QSqlField.requiredStatus (<i>self</i>)</h3><p>Returns true if this is a required field; otherwise returns false. An <tt>INSERT</tt> will fail if a required field does not have a value.</p>
69
<p>See also <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>(), <a href="qsqlfield.html#type">type</a>(), <a href="qsqlfield.html#length">length</a>(), <a href="qsqlfield.html#precision">precision</a>(), <a href="qsqlfield.html#defaultValue">defaultValue</a>(), and <a href="qsqlfield.html#isGenerated">isGenerated</a>().</p>
70
<a name="//apple_ref/cpp/instm/QSqlField/setAutoValue" />
71
<h3 class="fn"><a name="setAutoValue" />QSqlField.setAutoValue (<i>self</i>, bool)</h3><p>Marks the field as an auto-generated value if <i>autoVal</i> is true.</p>
139
<h3 class="fn"><a name="requiredStatus" /><a href="qsqlfield.html#RequiredStatus-enum">RequiredStatus</a> QSqlField.requiredStatus (<i>self</i>)</h3><p>Returns true if this is a required field; otherwise returns
140
false. An <tt>INSERT</tt> will fail if a required field does not
142
<p>See also <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>(),
143
<a href="qsqlfield.html#type">type</a>(), <a href="qsqlfield.html#length">length</a>(), <a href="qsqlfield.html#precision">precision</a>(), <a href="qsqlfield.html#defaultValue">defaultValue</a>(), and <a href="qsqlfield.html#isGenerated">isGenerated</a>().</p>
146
<h3 class="fn"><a name="setAutoValue" />QSqlField.setAutoValue (<i>self</i>, bool)</h3><p>Marks the field as an auto-generated value if <i>autoVal</i> is
72
148
<p>See also <a href="qsqlfield.html#isAutoValue">isAutoValue</a>().</p>
73
<a name="//apple_ref/cpp/instm/QSqlField/setDefaultValue" />
74
151
<h3 class="fn"><a name="setDefaultValue" />QSqlField.setDefaultValue (<i>self</i>, QVariant)</h3><p>Sets the default value used for this field to <i>value</i>.</p>
75
<p>See also <a href="qsqlfield.html#defaultValue">defaultValue</a>(), <a href="qsqlfield.html#value">value</a>(), <a href="qsqlfield.html#setType">setType</a>(), <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>(), <a href="qsqlfield.html#setLength">setLength</a>(), <a href="qsqlfield.html#setPrecision">setPrecision</a>(), <a href="qsqlfield.html#setGenerated">setGenerated</a>(), and <a href="qsqlfield.html#setReadOnly">setReadOnly</a>().</p>
76
<a name="//apple_ref/cpp/instm/QSqlField/setGenerated" />
77
<h3 class="fn"><a name="setGenerated" />QSqlField.setGenerated (<i>self</i>, bool)</h3><p>Sets the generated state. If <i>gen</i> is false, no SQL will be generated for this field; otherwise, Qt classes such as <a href="qsqlquerymodel.html">QSqlQueryModel</a> and <a href="qsqltablemodel.html">QSqlTableModel</a> will generate SQL for this field.</p>
78
<p>See also <a href="qsqlfield.html#isGenerated">isGenerated</a>(), <a href="qsqlfield.html#setType">setType</a>(), <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>(), <a href="qsqlfield.html#setLength">setLength</a>(), <a href="qsqlfield.html#setPrecision">setPrecision</a>(), <a href="qsqlfield.html#setDefaultValue">setDefaultValue</a>(), and <a href="qsqlfield.html#setReadOnly">setReadOnly</a>().</p>
79
<a name="//apple_ref/cpp/instm/QSqlField/setLength" />
80
<h3 class="fn"><a name="setLength" />QSqlField.setLength (<i>self</i>, int)</h3><p>Sets the field's length to <i>fieldLength</i>. For strings this is the maximum number of characters the string can hold; the meaning varies for other types.</p>
81
<p>See also <a href="qsqlfield.html#length">length</a>(), <a href="qsqlfield.html#setType">setType</a>(), <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>(), <a href="qsqlfield.html#setPrecision">setPrecision</a>(), <a href="qsqlfield.html#setDefaultValue">setDefaultValue</a>(), <a href="qsqlfield.html#setGenerated">setGenerated</a>(), and <a href="qsqlfield.html#setReadOnly">setReadOnly</a>().</p>
82
<a name="//apple_ref/cpp/instm/QSqlField/setName" />
152
<p>See also <a href="qsqlfield.html#defaultValue">defaultValue</a>(), <a href="qsqlfield.html#value">value</a>(), <a href="qsqlfield.html#setType">setType</a>(), <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>(),
153
<a href="qsqlfield.html#setLength">setLength</a>(), <a href="qsqlfield.html#setPrecision">setPrecision</a>(), <a href="qsqlfield.html#setGenerated">setGenerated</a>(), and <a href="qsqlfield.html#setReadOnly">setReadOnly</a>().</p>
156
<h3 class="fn"><a name="setGenerated" />QSqlField.setGenerated (<i>self</i>, bool)</h3><p>Sets the generated state. If <i>gen</i> is false, no SQL will be
157
generated for this field; otherwise, Qt classes such as <a href="qsqlquerymodel.html">QSqlQueryModel</a> and <a href="qsqltablemodel.html">QSqlTableModel</a> will generate SQL for this
159
<p>See also <a href="qsqlfield.html#isGenerated">isGenerated</a>(),
160
<a href="qsqlfield.html#setType">setType</a>(), <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>(),
161
<a href="qsqlfield.html#setLength">setLength</a>(), <a href="qsqlfield.html#setPrecision">setPrecision</a>(), <a href="qsqlfield.html#setDefaultValue">setDefaultValue</a>(), and
162
<a href="qsqlfield.html#setReadOnly">setReadOnly</a>().</p>
165
<h3 class="fn"><a name="setLength" />QSqlField.setLength (<i>self</i>, int)</h3><p>Sets the field's length to <i>fieldLength</i>. For strings this
166
is the maximum number of characters the string can hold; the
167
meaning varies for other types.</p>
168
<p>See also <a href="qsqlfield.html#length">length</a>(), <a href="qsqlfield.html#setType">setType</a>(), <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>(),
169
<a href="qsqlfield.html#setPrecision">setPrecision</a>(), <a href="qsqlfield.html#setDefaultValue">setDefaultValue</a>(), <a href="qsqlfield.html#setGenerated">setGenerated</a>(), and <a href="qsqlfield.html#setReadOnly">setReadOnly</a>().</p>
83
172
<h3 class="fn"><a name="setName" />QSqlField.setName (<i>self</i>, QString)</h3><p>Sets the name of the field to <i>name</i>.</p>
84
173
<p>See also <a href="qsqlfield.html#name">name</a>().</p>
85
<a name="//apple_ref/cpp/instm/QSqlField/setPrecision" />
86
<h3 class="fn"><a name="setPrecision" />QSqlField.setPrecision (<i>self</i>, int)</h3><p>Sets the field's <i>precision</i>. This only affects numeric fields.</p>
87
<p>See also <a href="qsqlfield.html#precision">precision</a>(), <a href="qsqlfield.html#setType">setType</a>(), <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>(), <a href="qsqlfield.html#setLength">setLength</a>(), <a href="qsqlfield.html#setDefaultValue">setDefaultValue</a>(), <a href="qsqlfield.html#setGenerated">setGenerated</a>(), and <a href="qsqlfield.html#setReadOnly">setReadOnly</a>().</p>
88
<a name="//apple_ref/cpp/instm/QSqlField/setReadOnly" />
89
<h3 class="fn"><a name="setReadOnly" />QSqlField.setReadOnly (<i>self</i>, bool)</h3><p>Sets the read only flag of the field's value to <i>readOnly</i>. A read-only field cannot have its value set with <a href="qsqlfield.html#setValue">setValue</a>() and cannot be cleared to NULL with <a href="qsqlfield.html#clear">clear</a>().</p>
176
<h3 class="fn"><a name="setPrecision" />QSqlField.setPrecision (<i>self</i>, int)</h3><p>Sets the field's <i>precision</i>. This only affects numeric
178
<p>See also <a href="qsqlfield.html#precision">precision</a>(),
179
<a href="qsqlfield.html#setType">setType</a>(), <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>(),
180
<a href="qsqlfield.html#setLength">setLength</a>(), <a href="qsqlfield.html#setDefaultValue">setDefaultValue</a>(), <a href="qsqlfield.html#setGenerated">setGenerated</a>(), and <a href="qsqlfield.html#setReadOnly">setReadOnly</a>().</p>
183
<h3 class="fn"><a name="setReadOnly" />QSqlField.setReadOnly (<i>self</i>, bool)</h3><p>Sets the read only flag of the field's value to <i>readOnly</i>.
184
A read-only field cannot have its value set with <a href="qsqlfield.html#setValue">setValue</a>() and cannot be cleared to
185
NULL with <a href="qsqlfield.html#clear">clear</a>().</p>
90
186
<p>See also <a href="qsqlfield.html#isReadOnly">isReadOnly</a>().</p>
91
<a name="//apple_ref/cpp/instm/QSqlField/setRequired" />
92
<h3 class="fn"><a name="setRequired" />QSqlField.setRequired (<i>self</i>, bool)</h3><p>Sets the required status of this field to <a href="qsqlfield.html#RequiredStatus-enum">Required</a> if <i>required</i> is true; otherwise sets it to <a href="qsqlfield.html#RequiredStatus-enum">Optional</a>.</p>
93
<p>See also <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>() and <a href="qsqlfield.html#requiredStatus">requiredStatus</a>().</p>
94
<a name="//apple_ref/cpp/instm/QSqlField/setRequiredStatus" />
189
<h3 class="fn"><a name="setRequired" />QSqlField.setRequired (<i>self</i>, bool)</h3><p>Sets the required status of this field to <a href="qsqlfield.html#RequiredStatus-enum">Required</a> if
190
<i>required</i> is true; otherwise sets it to <a href="qsqlfield.html#RequiredStatus-enum">Optional</a>.</p>
191
<p>See also <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>() and
192
<a href="qsqlfield.html#requiredStatus">requiredStatus</a>().</p>
95
195
<h3 class="fn"><a name="setRequiredStatus" />QSqlField.setRequiredStatus (<i>self</i>, <a href="qsqlfield.html#RequiredStatus-enum">RequiredStatus</a>)</h3><p>Sets the required status of this field to <i>required</i>.</p>
96
196
<p>See also <a href="qsqlfield.html#requiredStatus">requiredStatus</a>(), <a href="qsqlfield.html#setType">setType</a>(), <a href="qsqlfield.html#setLength">setLength</a>(), <a href="qsqlfield.html#setPrecision">setPrecision</a>(), <a href="qsqlfield.html#setDefaultValue">setDefaultValue</a>(), <a href="qsqlfield.html#setGenerated">setGenerated</a>(), and <a href="qsqlfield.html#setReadOnly">setReadOnly</a>().</p>
97
<a name="//apple_ref/cpp/instm/QSqlField/setType" />
98
199
<h3 class="fn"><a name="setSqlType" />QSqlField.setSqlType (<i>self</i>, int)</h3><h3 class="fn"><a name="setType" />QSqlField.setType (<i>self</i>, <a href="qvariant.html#Type-enum">QVariant.Type</a>)</h3><p>Set's the field's variant type to <i>type</i>.</p>
99
<p>See also <a href="qsqlfield.html#type">type</a>(), <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>(), <a href="qsqlfield.html#setLength">setLength</a>(), <a href="qsqlfield.html#setPrecision">setPrecision</a>(), <a href="qsqlfield.html#setDefaultValue">setDefaultValue</a>(), <a href="qsqlfield.html#setGenerated">setGenerated</a>(), and <a href="qsqlfield.html#setReadOnly">setReadOnly</a>().</p>
100
<a name="//apple_ref/cpp/instm/QSqlField/setValue" />
101
<h3 class="fn"><a name="setValue" />QSqlField.setValue (<i>self</i>, QVariant)</h3><p>Sets the value of the field to <i>value</i>. If the field is read-only (<a href="qsqlfield.html#isReadOnly">isReadOnly</a>() returns true), nothing happens.</p>
102
<p>If the data type of <i>value</i> 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 <a href="qstring.html">QString</a> to an integer data type.</p>
200
<p>See also <a href="qsqlfield.html#type">type</a>(), <a href="qsqlfield.html#setRequiredStatus">setRequiredStatus</a>(),
201
<a href="qsqlfield.html#setLength">setLength</a>(), <a href="qsqlfield.html#setPrecision">setPrecision</a>(), <a href="qsqlfield.html#setDefaultValue">setDefaultValue</a>(), <a href="qsqlfield.html#setGenerated">setGenerated</a>(), and <a href="qsqlfield.html#setReadOnly">setReadOnly</a>().</p>
204
<h3 class="fn"><a name="setValue" />QSqlField.setValue (<i>self</i>, QVariant)</h3><p>Sets the value of the field to <i>value</i>. If the field is
205
read-only (<a href="qsqlfield.html#isReadOnly">isReadOnly</a>()
206
returns true), nothing happens.</p>
207
<p>If the data type of <i>value</i> differs from the field's
208
current data type, an attempt is made to cast it to the proper
209
type. This preserves the data type of the field in the case of
210
assignment, e.g. a <a href="qstring.html">QString</a> to an integer
103
212
<p>To set the value to NULL, use <a href="qsqlfield.html#clear">clear</a>().</p>
104
213
<p>See also <a href="qsqlfield.html#value">value</a>(), <a href="qsqlfield.html#isReadOnly">isReadOnly</a>(), and <a href="qsqlfield.html#defaultValue">defaultValue</a>().</p>
105
<a name="//apple_ref/cpp/instm/QSqlField/type" />
106
<h3 class="fn"><a name="type" /><a href="qvariant.html#Type-enum">QVariant.Type</a> QSqlField.type (<i>self</i>)</h3><p>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.</p>
216
<h3 class="fn"><a name="type" /><a href="qvariant.html#Type-enum">QVariant.Type</a> QSqlField.type (<i>self</i>)</h3><p>Returns the field's type as stored in the database. Note that
217
the actual value might have a different type, Numerical values that
218
are too large to store in a long int or double are usually stored
219
as strings to prevent precision loss.</p>
107
220
<p>See also <a href="qsqlfield.html#setType">setType</a>().</p>
108
<a name="//apple_ref/cpp/instm/QSqlField/value" />
109
223
<h3 class="fn"><a name="typeID" />int QSqlField.typeID (<i>self</i>)</h3><h3 class="fn"><a name="value" />QVariant QSqlField.value (<i>self</i>)</h3><p>Returns the value of the field as a <a href="qvariant.html">QVariant</a>.</p>
110
<p>Use <a href="qsqlfield.html#isNull">isNull</a>() to check if the field's value is NULL.</p>
224
<p>Use <a href="qsqlfield.html#isNull">isNull</a>() to check if the
225
field's value is NULL.</p>
111
226
<p>See also <a href="qsqlfield.html#setValue">setValue</a>().</p>
112
<a name="//apple_ref/cpp/instm/QSqlField/operator!=" />
113
<h3 class="fn"><a name="__eq__" />bool QSqlField.__eq__ (<i>self</i>, <a href="qsqlfield.html">QSqlField</a>)</h3><h3 class="fn"><a name="__ne__" />bool QSqlField.__ne__ (<i>self</i>, <a href="qsqlfield.html">QSqlField</a>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.7.7 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt 4.6.3</td></tr></table></div></address></body></html>
b'\\ No newline at end of file'
229
<h3 class="fn"><a name="__eq__" />bool QSqlField.__eq__ (<i>self</i>, <a href="qsqlfield.html">QSqlField</a>)</h3><h3 class="fn"><a name="__ne__" />bool QSqlField.__ne__ (<i>self</i>, <a href="qsqlfield.html">QSqlField</a>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.8.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2010</td><td align="right" width="25%">Qt 4.7.0</td></tr></table></div></address></body></html>
b'\\ No newline at end of file'