source: trunk/doc/html/qdatatable.html@ 190

Last change on this file since 190 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 56.0 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/sql/qdatatable.cpp:130 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QDataTable Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QDataTable Class Reference<br><small>[<a href="sql.html">sql module</a>]</small></h1>
33
34<p>The QDataTable class provides a flexible SQL table widget that supports browsing and editing.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qdatatable-h.html">qdatatable.h</a>&gt;</tt>
37<p>Inherits <a href="qtable.html">QTable</a>.
38<p><a href="qdatatable-members.html">List of all member functions.</a>
39<h2>Public Members</h2>
40<ul>
41<li class=fn><a href="#QDataTable"><b>QDataTable</b></a> ( QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
42<li class=fn><a href="#QDataTable-2"><b>QDataTable</b></a> ( QSqlCursor&nbsp;*&nbsp;cursor, bool&nbsp;autoPopulate = FALSE, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
43<li class=fn><a href="#~QDataTable"><b>~QDataTable</b></a> ()</li>
44<li class=fn>virtual void <a href="#addColumn"><b>addColumn</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;fieldName, const&nbsp;QString&nbsp;&amp;&nbsp;label = QString::null, int&nbsp;width = -1, const&nbsp;QIconSet&nbsp;&amp;&nbsp;iconset = QIconSet ( ) )</li>
45<li class=fn>virtual void <a href="#removeColumn"><b>removeColumn</b></a> ( uint&nbsp;col )</li>
46<li class=fn>virtual void <a href="#setColumn"><b>setColumn</b></a> ( uint&nbsp;col, const&nbsp;QString&nbsp;&amp;&nbsp;fieldName, const&nbsp;QString&nbsp;&amp;&nbsp;label = QString::null, int&nbsp;width = -1, const&nbsp;QIconSet&nbsp;&amp;&nbsp;iconset = QIconSet ( ) )</li>
47<li class=fn>QString <a href="#nullText"><b>nullText</b></a> () const</li>
48<li class=fn>QString <a href="#trueText"><b>trueText</b></a> () const</li>
49<li class=fn>QString <a href="#falseText"><b>falseText</b></a> () const</li>
50<li class=fn>DateFormat <a href="#dateFormat"><b>dateFormat</b></a> () const</li>
51<li class=fn>bool <a href="#confirmEdits"><b>confirmEdits</b></a> () const</li>
52<li class=fn>bool <a href="#confirmInsert"><b>confirmInsert</b></a> () const</li>
53<li class=fn>bool <a href="#confirmUpdate"><b>confirmUpdate</b></a> () const</li>
54<li class=fn>bool <a href="#confirmDelete"><b>confirmDelete</b></a> () const</li>
55<li class=fn>bool <a href="#confirmCancels"><b>confirmCancels</b></a> () const</li>
56<li class=fn>bool <a href="#autoDelete"><b>autoDelete</b></a> () const</li>
57<li class=fn>bool <a href="#autoEdit"><b>autoEdit</b></a> () const</li>
58<li class=fn>QString <a href="#filter"><b>filter</b></a> () const</li>
59<li class=fn>QStringList <a href="#sort"><b>sort</b></a> () const</li>
60<li class=fn>virtual void <a href="#setSqlCursor"><b>setSqlCursor</b></a> ( QSqlCursor&nbsp;*&nbsp;cursor = 0, bool&nbsp;autoPopulate = FALSE, bool&nbsp;autoDelete = FALSE )</li>
61<li class=fn>QSqlCursor * <a href="#sqlCursor"><b>sqlCursor</b></a> () const</li>
62<li class=fn>virtual void <a href="#setNullText"><b>setNullText</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;nullText )</li>
63<li class=fn>virtual void <a href="#setTrueText"><b>setTrueText</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;trueText )</li>
64<li class=fn>virtual void <a href="#setFalseText"><b>setFalseText</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;falseText )</li>
65<li class=fn>virtual void <a href="#setDateFormat"><b>setDateFormat</b></a> ( const&nbsp;DateFormat&nbsp;f )</li>
66<li class=fn>virtual void <a href="#setConfirmEdits"><b>setConfirmEdits</b></a> ( bool&nbsp;confirm )</li>
67<li class=fn>virtual void <a href="#setConfirmInsert"><b>setConfirmInsert</b></a> ( bool&nbsp;confirm )</li>
68<li class=fn>virtual void <a href="#setConfirmUpdate"><b>setConfirmUpdate</b></a> ( bool&nbsp;confirm )</li>
69<li class=fn>virtual void <a href="#setConfirmDelete"><b>setConfirmDelete</b></a> ( bool&nbsp;confirm )</li>
70<li class=fn>virtual void <a href="#setConfirmCancels"><b>setConfirmCancels</b></a> ( bool&nbsp;confirm )</li>
71<li class=fn>virtual void <a href="#setAutoDelete"><b>setAutoDelete</b></a> ( bool&nbsp;enable )</li>
72<li class=fn>virtual void <a href="#setAutoEdit"><b>setAutoEdit</b></a> ( bool&nbsp;autoEdit )</li>
73<li class=fn>virtual void <a href="#setFilter"><b>setFilter</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;filter )</li>
74<li class=fn>virtual void <a href="#setSort"><b>setSort</b></a> ( const&nbsp;QStringList&nbsp;&amp;&nbsp;sort )</li>
75<li class=fn>virtual void <a href="#setSort-2"><b>setSort</b></a> ( const&nbsp;QSqlIndex&nbsp;&amp;&nbsp;sort )</li>
76<li class=fn>enum <a href="#Refresh-enum"><b>Refresh</b></a> { RefreshData = 1, RefreshColumns = 2, RefreshAll = 3 }</li>
77<li class=fn>void <a href="#refresh-2"><b>refresh</b></a> ( Refresh&nbsp;mode )</li>
78<li class=fn>virtual void <a href="#sortColumn"><b>sortColumn</b></a> ( int&nbsp;col, bool&nbsp;ascending = TRUE, bool&nbsp;wholeRows = FALSE )</li>
79<li class=fn>virtual QString <a href="#text"><b>text</b></a> ( int&nbsp;row, int&nbsp;col ) const</li>
80<li class=fn>QVariant <a href="#value"><b>value</b></a> ( int&nbsp;row, int&nbsp;col ) const</li>
81<li class=fn>QSqlRecord * <a href="#currentRecord"><b>currentRecord</b></a> () const</li>
82<li class=fn>void <a href="#installEditorFactory"><b>installEditorFactory</b></a> ( QSqlEditorFactory&nbsp;*&nbsp;f )</li>
83<li class=fn>void <a href="#installPropertyMap"><b>installPropertyMap</b></a> ( QSqlPropertyMap&nbsp;*&nbsp;m )</li>
84<li class=fn>virtual int <a href="#numCols"><b>numCols</b></a> () const</li>
85<li class=fn>virtual int <a href="#numRows"><b>numRows</b></a> () const</li>
86</ul>
87<h2>Public Slots</h2>
88<ul>
89<li class=fn>virtual void <a href="#find"><b>find</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;str, bool&nbsp;caseSensitive, bool&nbsp;backwards )</li>
90<li class=fn>virtual void <a href="#sortAscending"><b>sortAscending</b></a> ( int&nbsp;col )</li>
91<li class=fn>virtual void <a href="#sortDescending"><b>sortDescending</b></a> ( int&nbsp;col )</li>
92<li class=fn>virtual void <a href="#refresh"><b>refresh</b></a> ()</li>
93<li class=fn>virtual void <a href="#setColumnWidth"><b>setColumnWidth</b></a> ( int&nbsp;col, int&nbsp;w )</li>
94<li class=fn>virtual void <a href="#adjustColumn"><b>adjustColumn</b></a> ( int&nbsp;col )</li>
95</ul>
96<h2>Signals</h2>
97<ul>
98<li class=fn>void <a href="#currentChanged"><b>currentChanged</b></a> ( QSqlRecord&nbsp;*&nbsp;record )</li>
99<li class=fn>void <a href="#primeInsert"><b>primeInsert</b></a> ( QSqlRecord&nbsp;*&nbsp;buf )</li>
100<li class=fn>void <a href="#primeUpdate"><b>primeUpdate</b></a> ( QSqlRecord&nbsp;*&nbsp;buf )</li>
101<li class=fn>void <a href="#primeDelete"><b>primeDelete</b></a> ( QSqlRecord&nbsp;*&nbsp;buf )</li>
102<li class=fn>void <a href="#beforeInsert"><b>beforeInsert</b></a> ( QSqlRecord&nbsp;*&nbsp;buf )</li>
103<li class=fn>void <a href="#beforeUpdate"><b>beforeUpdate</b></a> ( QSqlRecord&nbsp;*&nbsp;buf )</li>
104<li class=fn>void <a href="#beforeDelete"><b>beforeDelete</b></a> ( QSqlRecord&nbsp;*&nbsp;buf )</li>
105<li class=fn>void <a href="#cursorChanged"><b>cursorChanged</b></a> ( QSql::Op&nbsp;mode )</li>
106</ul>
107<h2>Properties</h2>
108<ul>
109<li class=fn>bool <a href="#autoEdit-prop"><b>autoEdit</b></a>&nbsp;- whether the data table automatically applies edits</li>
110<li class=fn>bool <a href="#confirmCancels-prop"><b>confirmCancels</b></a>&nbsp;- whether the data table confirms cancel operations</li>
111<li class=fn>bool <a href="#confirmDelete-prop"><b>confirmDelete</b></a>&nbsp;- whether the data table confirms delete operations</li>
112<li class=fn>bool <a href="#confirmEdits-prop"><b>confirmEdits</b></a>&nbsp;- whether the data table confirms edit operations</li>
113<li class=fn>bool <a href="#confirmInsert-prop"><b>confirmInsert</b></a>&nbsp;- whether the data table confirms insert operations</li>
114<li class=fn>bool <a href="#confirmUpdate-prop"><b>confirmUpdate</b></a>&nbsp;- whether the data table confirms update operations</li>
115<li class=fn>DateFormat <a href="#dateFormat-prop"><b>dateFormat</b></a>&nbsp;- the format used for displaying date/time values</li>
116<li class=fn>QString <a href="#falseText-prop"><b>falseText</b></a>&nbsp;- the text used to represent false values</li>
117<li class=fn>QString <a href="#filter-prop"><b>filter</b></a>&nbsp;- the data filter for the data table</li>
118<li class=fn>QString <a href="#nullText-prop"><b>nullText</b></a>&nbsp;- the text used to represent NULL values</li>
119<li class=fn>int <a href="#numCols-prop"><b>numCols</b></a>&nbsp;- the number of columns in the table &nbsp;<em>(read only)</em></li>
120<li class=fn>int <a href="#numRows-prop"><b>numRows</b></a>&nbsp;- the number of rows in the table &nbsp;<em>(read only)</em></li>
121<li class=fn>QStringList <a href="#sort-prop"><b>sort</b></a>&nbsp;- the data table's sort</li>
122<li class=fn>QString <a href="#trueText-prop"><b>trueText</b></a>&nbsp;- the text used to represent true values</li>
123</ul>
124<h2>Protected Members</h2>
125<ul>
126<li class=fn>virtual bool <a href="#insertCurrent"><b>insertCurrent</b></a> ()</li>
127<li class=fn>virtual bool <a href="#updateCurrent"><b>updateCurrent</b></a> ()</li>
128<li class=fn>virtual bool <a href="#deleteCurrent"><b>deleteCurrent</b></a> ()</li>
129<li class=fn>virtual QSql::Confirm <a href="#confirmEdit"><b>confirmEdit</b></a> ( QSql::Op&nbsp;m )</li>
130<li class=fn>virtual QSql::Confirm <a href="#confirmCancel"><b>confirmCancel</b></a> ( QSql::Op&nbsp;m )</li>
131<li class=fn>virtual void <a href="#handleError"><b>handleError</b></a> ( const&nbsp;QSqlError&nbsp;&amp;&nbsp;e )</li>
132<li class=fn>virtual bool <a href="#beginInsert"><b>beginInsert</b></a> ()</li>
133<li class=fn>virtual QWidget * <a href="#beginUpdate"><b>beginUpdate</b></a> ( int&nbsp;row, int&nbsp;col, bool&nbsp;replace )</li>
134<li class=fn>int <a href="#indexOf"><b>indexOf</b></a> ( uint&nbsp;i ) const</li>
135<li class=fn>void <a href="#reset"><b>reset</b></a> ()</li>
136<li class=fn>void <a href="#setSize"><b>setSize</b></a> ( QSqlCursor&nbsp;*&nbsp;sql )</li>
137<li class=fn>virtual void <a href="#paintField"><b>paintField</b></a> ( QPainter&nbsp;*&nbsp;p, const&nbsp;QSqlField&nbsp;*&nbsp;field, const&nbsp;QRect&nbsp;&amp;&nbsp;cr, bool&nbsp;selected )</li>
138<li class=fn>virtual int <a href="#fieldAlignment"><b>fieldAlignment</b></a> ( const&nbsp;QSqlField&nbsp;*&nbsp;field )</li>
139</ul>
140<hr><a name="details"></a><h2>Detailed Description</h2>
141
142
143The QDataTable class provides a flexible SQL table widget that supports browsing and editing.
144<p>
145
146
147<p> QDataTable supports various functions for presenting and editing
148SQL data from a <a href="qsqlcursor.html">QSqlCursor</a> in a table.
149<p> If you want a to present your data in a form use <a href="qdatabrowser.html">QDataBrowser</a>, or
150for read-only forms, <a href="qdataview.html">QDataView</a>.
151<p> When displaying data, QDataTable only retrieves data for visible
152rows. If the driver supports the 'query size' property the
153QDataTable will have the correct number of rows and the vertical
154scrollbar will accurately reflect the number of rows displayed in
155proportion to the number of rows in the dataset. If the driver
156does not support the 'query size' property, rows are dynamically
157fetched from the database on an as-needed basis with the scrollbar
158becoming more accurate as the user scrolls down through the
159records. This allows extremely large queries to be displayed as
160quickly as possible, with minimum memory usage.
161<p> QDataTable inherits <a href="qtable.html">QTable</a>'s API and extends it with functions to
162sort and filter the data and sort columns. See <a href="#setSqlCursor">setSqlCursor</a>(),
163<a href="#setFilter">setFilter</a>(), <a href="#setSort">setSort</a>(), <a href="qtable.html#setSorting">setSorting</a>(), <a href="#sortColumn">sortColumn</a>() and <a href="#refresh">refresh</a>().
164<p> When displaying editable cursors, cell editing will be enabled.
165(For more information on editable cursors, see <a href="qsqlcursor.html">QSqlCursor</a>).
166QDataTable can be used to modify existing data and to add new
167records. When a user makes changes to a field in the table, the
168cursor's edit buffer is used. The table will not send changes in
169the edit buffer to the database until the user moves to a
170different record in the grid or presses Enter. Cell editing is
171initiated by pressing F2 (or right clicking and then clicking the
172appropriate popup menu item) and canceled by pressing Esc. If
173there is a problem updating or adding data, errors are handled
174automatically (see <a href="#handleError">handleError</a>() to change this behavior). Note
175that if <a href="#autoEdit">autoEdit</a>() is FALSE navigating to another record will
176cancel the insert or update.
177<p> The user can be asked to confirm all edits with <a href="#setConfirmEdits">setConfirmEdits</a>().
178For more precise control use <a href="#setConfirmInsert">setConfirmInsert</a>(),
179<a href="#setConfirmUpdate">setConfirmUpdate</a>(), <a href="#setConfirmDelete">setConfirmDelete</a>() and <a href="#setConfirmCancels">setConfirmCancels</a>().
180Use <a href="#setAutoEdit">setAutoEdit</a>() to control the behaviour of the table when the
181user edits a record and then navigates. (Note that <a href="#setAutoDelete">setAutoDelete</a>()
182is unrelated; it is used to set whether the <a href="qsqlcursor.html">QSqlCursor</a> is deleted
183when the table is deleted.)
184<p> Since the data table can perform edits, it must be able to
185uniquely identify every record so that edits are correctly
186applied. Because of this the underlying cursor must have a valid
187primary index to ensure that a unique record is inserted, updated
188or deleted within the database otherwise the database may be
189changed to an inconsistent state.
190<p> QDataTable creates editors using the default <a href="qsqleditorfactory.html">QSqlEditorFactory</a>.
191Different editor factories can be used by calling
192<a href="#installEditorFactory">installEditorFactory</a>(). A property map is used to map between the
193cell's value and the editor. You can use your own property map
194with <a href="#installPropertyMap">installPropertyMap</a>().
195<p> The contents of a cell is available as a <a href="qstring.html">QString</a> with <a href="#text">text</a>() or as
196a <a href="qvariant.html">QVariant</a> with <a href="#value">value</a>(). The current record is returned by
197<a href="#currentRecord">currentRecord</a>(). Use the <a href="#find">find</a>() function to search for a string in
198the table.
199<p> Editing actions can be applied programatically. For example, the
200<a href="#insertCurrent">insertCurrent</a>() function reads the fields from the current record
201into the cursor and performs the insert. The <a href="#updateCurrent">updateCurrent</a>() and
202<a href="#deleteCurrent">deleteCurrent</a>() functions perform similarly to update and delete
203the current record respectively.
204<p> Columns in the table can be created automatically based on the
205cursor (see <a href="#setSqlCursor">setSqlCursor</a>()). Columns can be manipulated manually
206using <a href="#addColumn">addColumn</a>(), <a href="#removeColumn">removeColumn</a>() and <a href="#setColumn">setColumn</a>().
207<p> The table automatically copies many of the properties of the
208cursor to format the display of data within cells (alignment,
209visibility, etc.). The cursor can be changed with setSqlCursor().
210The filter (see <a href="#setFilter">setFilter</a>()) and sort defined within the table are
211used instead of the filter and sort set on the cursor. For sorting
212options see <a href="#setSort">setSort</a>(), <a href="#sortColumn">sortColumn</a>(), <a href="#sortAscending">sortAscending</a>() and
213<a href="#sortDescending">sortDescending</a>(). Note that sorting operations will not behave as
214expected if you are using a <a href="qsqlselectcursor.html">QSqlSelectCursor</a> because it uses
215user-defined SQL queries to obtain data.
216<p> The text used to represent NULL, TRUE and FALSE values can be
217changed with <a href="#setNullText">setNullText</a>(), <a href="#setTrueText">setTrueText</a>() and <a href="#setFalseText">setFalseText</a>()
218respectively. You can change the appearance of cells by
219reimplementing <a href="#paintField">paintField</a>().
220<p> Whenever a new row is selected in the table the <a href="#currentChanged">currentChanged</a>()
221signal is emitted. The <a href="#primeInsert">primeInsert</a>() signal is emitted when an
222insert is initiated. The <a href="#primeUpdate">primeUpdate</a>() and <a href="#primeDelete">primeDelete</a>() signals
223are emitted when update and deletion are initiated respectively.
224Just before the database is updated a signal is emitted;
225<a href="#beforeInsert">beforeInsert</a>(), <a href="#beforeUpdate">beforeUpdate</a>() or <a href="#beforeDelete">beforeDelete</a>() as appropriate.
226<p> <p>See also <a href="database.html">Database Classes</a>.
227
228<hr><h2>Member Type Documentation</h2>
229<h3 class=fn><a name="Refresh-enum"></a>QDataTable::Refresh</h3>
230
231<p> This enum describes the refresh options.
232<ul>
233<li><tt>QDataTable::RefreshData</tt> - refresh the data, i.e. read it from the database
234<li><tt>QDataTable::RefreshColumns</tt> - refresh the list of fields, e.g. the column headings
235<li><tt>QDataTable::RefreshAll</tt> - refresh both the data and the list of fields
236</ul>
237<hr><h2>Member Function Documentation</h2>
238<h3 class=fn><a name="QDataTable"></a>QDataTable::QDataTable ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
239</h3>
240Constructs a data table which is a child of <em>parent</em>, called
241name <em>name</em>.
242
243<h3 class=fn><a name="QDataTable-2"></a>QDataTable::QDataTable ( <a href="qsqlcursor.html">QSqlCursor</a>&nbsp;*&nbsp;cursor, bool&nbsp;autoPopulate = FALSE, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
244</h3>
245Constructs a data table which is a child of <em>parent</em>, called name
246<em>name</em> using the cursor <em>cursor</em>.
247<p> If <em>autoPopulate</em> is TRUE (the default is FALSE), columns are
248automatically created based upon the fields in the <em>cursor</em>
249record. Note that <em>autoPopulate</em> only governs the creation of
250columns; to load the cursor's data into the table use <a href="#refresh">refresh</a>().
251<p> If the <em>cursor</em> is read-only, the table also becomes read-only.
252In addition, the table adopts the cursor's driver's definition for
253representing NULL values as strings.
254
255<h3 class=fn><a name="~QDataTable"></a>QDataTable::~QDataTable ()
256</h3>
257Destroys the object and frees any allocated resources.
258
259<h3 class=fn>void <a name="addColumn"></a>QDataTable::addColumn ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fieldName, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;label = QString::null, int&nbsp;width = -1, const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;iconset = QIconSet ( ) )<tt> [virtual]</tt>
260</h3>
261Adds the next column to be displayed using the field <em>fieldName</em>,
262column label <em>label</em>, width <em>width</em> and iconset <em>iconset</em>.
263<p> If <em>label</em> is specified, it is used as the column's header label,
264otherwise the field's display label is used when <a href="#setSqlCursor">setSqlCursor</a>() is
265called. The <em>iconset</em> is used to set the icon used by the column
266header; by default there is no icon.
267<p> <p>See also <a href="#setSqlCursor">setSqlCursor</a>() and <a href="#refresh">refresh</a>().
268
269<p>Examples: <a href="sql.html#x2255">sql/overview/subclass1/main.cpp</a>, <a href="sql.html#x2258">sql/overview/subclass3/main.cpp</a>, <a href="sql.html#x2214">sql/overview/table2/main.cpp</a>, and <a href="sqltable-example.html#x2451">sql/sqltable/main.cpp</a>.
270<h3 class=fn>void <a name="adjustColumn"></a>QDataTable::adjustColumn ( int&nbsp;col )<tt> [virtual slot]</tt>
271</h3>
272Resizes column <em>col</em> so that the column width is wide enough to
273display the widest item the column contains (including the column
274label). If the table's <a href="qsqlcursor.html">QSqlCursor</a> is not currently active, the
275cursor will be refreshed before the column width is calculated. Be
276aware that this function may be slow on tables that contain large
277result sets.
278
279<p>Reimplemented from <a href="qtable.html#adjustColumn">QTable</a>.
280<h3 class=fn>bool <a name="autoDelete"></a>QDataTable::autoDelete () const
281</h3>
282Returns TRUE if the table will automatically delete the cursor
283specified by <a href="#setSqlCursor">setSqlCursor</a>(); otherwise returns FALSE.
284
285<h3 class=fn>bool <a name="autoEdit"></a>QDataTable::autoEdit () const
286</h3><p>Returns TRUE if the data table automatically applies edits; otherwise returns FALSE.
287See the <a href="qdatatable.html#autoEdit-prop">"autoEdit"</a> property for details.
288<h3 class=fn>void <a name="beforeDelete"></a>QDataTable::beforeDelete ( <a href="qsqlrecord.html">QSqlRecord</a>&nbsp;*&nbsp;buf )<tt> [signal]</tt>
289</h3>
290
291<p> This signal is emitted just before the currently selected record
292is deleted from the database. The <em>buf</em> parameter points to the
293edit buffer being deleted. Connect to this signal to, for example,
294copy some of the fields for later use.
295
296<h3 class=fn>void <a name="beforeInsert"></a>QDataTable::beforeInsert ( <a href="qsqlrecord.html">QSqlRecord</a>&nbsp;*&nbsp;buf )<tt> [signal]</tt>
297</h3>
298
299<p> This signal is emitted just before the cursor's edit buffer is
300inserted into the database. The <em>buf</em> parameter points to the
301edit buffer being inserted. Connect to this signal to, for
302example, populate a key field with a unique sequence number.
303
304<h3 class=fn>void <a name="beforeUpdate"></a>QDataTable::beforeUpdate ( <a href="qsqlrecord.html">QSqlRecord</a>&nbsp;*&nbsp;buf )<tt> [signal]</tt>
305</h3>
306
307<p> This signal is emitted just before the cursor's edit buffer is
308updated in the database. The <em>buf</em> parameter points to the edit
309buffer being updated. Connect to this signal when you want to
310transform the user's data behind-the-scenes.
311
312<h3 class=fn>bool <a name="beginInsert"></a>QDataTable::beginInsert ()<tt> [virtual protected]</tt>
313</h3>
314Protected virtual function called when editing is about to begin
315on a new record. If the table is read-only, or if there's no
316cursor or the cursor does not allow inserts, nothing happens.
317<p> Editing takes place using the cursor's edit buffer(see
318<a href="qsqlcursor.html#editBuffer">QSqlCursor::editBuffer</a>()).
319<p> When editing begins, a new row is created in the table marked with
320an asterisk '*' in the row's vertical header column, i.e. at the
321left of the row.
322
323<h3 class=fn><a href="qwidget.html">QWidget</a>&nbsp;* <a name="beginUpdate"></a>QDataTable::beginUpdate ( int&nbsp;row, int&nbsp;col, bool&nbsp;replace )<tt> [virtual protected]</tt>
324</h3>
325Protected virtual function called when editing is about to begin
326on an existing row. If the table is read-only, or if there's no
327cursor, nothing happens.
328<p> Editing takes place using the cursor's edit buffer (see
329<a href="qsqlcursor.html#editBuffer">QSqlCursor::editBuffer</a>()).
330<p> <em>row</em> and <em>col</em> refer to the row and column in the QDataTable.
331<p> (<em>replace</em> is provided for reimplementors and reflects the API of
332<a href="qtable.html#beginEdit">QTable::beginEdit</a>().)
333
334<h3 class=fn><a href="qsql.html#Confirm-enum">QSql::Confirm</a> <a name="confirmCancel"></a>QDataTable::confirmCancel ( <a href="qsql.html#Op-enum">QSql::Op</a>&nbsp;m )<tt> [virtual protected]</tt>
335</h3>
336Protected virtual function which returns a confirmation for
337cancelling an edit mode of <em>m</em>. Derived classes can reimplement
338this function to provide their own cancel dialog. The default
339implementation uses a message box which prompts the user to
340confirm the cancel.
341
342<h3 class=fn>bool <a name="confirmCancels"></a>QDataTable::confirmCancels () const
343</h3><p>Returns TRUE if the data table confirms cancel operations; otherwise returns FALSE.
344See the <a href="qdatatable.html#confirmCancels-prop">"confirmCancels"</a> property for details.
345<h3 class=fn>bool <a name="confirmDelete"></a>QDataTable::confirmDelete () const
346</h3><p>Returns TRUE if the data table confirms delete operations; otherwise returns FALSE.
347See the <a href="qdatatable.html#confirmDelete-prop">"confirmDelete"</a> property for details.
348<h3 class=fn><a href="qsql.html#Confirm-enum">QSql::Confirm</a> <a name="confirmEdit"></a>QDataTable::confirmEdit ( <a href="qsql.html#Op-enum">QSql::Op</a>&nbsp;m )<tt> [virtual protected]</tt>
349</h3>
350Protected virtual function which returns a confirmation for an
351edit of mode <em>m</em>. Derived classes can reimplement this function
352to provide their own confirmation dialog. The default
353implementation uses a message box which prompts the user to
354confirm the edit action.
355
356<h3 class=fn>bool <a name="confirmEdits"></a>QDataTable::confirmEdits () const
357</h3><p>Returns TRUE if the data table confirms edit operations; otherwise returns FALSE.
358See the <a href="qdatatable.html#confirmEdits-prop">"confirmEdits"</a> property for details.
359<h3 class=fn>bool <a name="confirmInsert"></a>QDataTable::confirmInsert () const
360</h3><p>Returns TRUE if the data table confirms insert operations; otherwise returns FALSE.
361See the <a href="qdatatable.html#confirmInsert-prop">"confirmInsert"</a> property for details.
362<h3 class=fn>bool <a name="confirmUpdate"></a>QDataTable::confirmUpdate () const
363</h3><p>Returns TRUE if the data table confirms update operations; otherwise returns FALSE.
364See the <a href="qdatatable.html#confirmUpdate-prop">"confirmUpdate"</a> property for details.
365<h3 class=fn>void <a name="currentChanged"></a>QDataTable::currentChanged ( <a href="qsqlrecord.html">QSqlRecord</a>&nbsp;*&nbsp;record )<tt> [signal]</tt>
366</h3>
367
368<p> This signal is emitted whenever a new row is selected in the
369table. The <em>record</em> parameter points to the contents of the newly
370selected record.
371
372<h3 class=fn><a href="qsqlrecord.html">QSqlRecord</a>&nbsp;* <a name="currentRecord"></a>QDataTable::currentRecord () const
373</h3>
374Returns the currently selected record, or 0 if there is no current
375selection. The table owns the pointer, so do <em>not</em> delete it or
376otherwise modify it or the cursor it points to.
377
378<h3 class=fn>void <a name="cursorChanged"></a>QDataTable::cursorChanged ( <a href="qsql.html#Op-enum">QSql::Op</a>&nbsp;mode )<tt> [signal]</tt>
379</h3>
380
381<p> This signal is emitted whenever the cursor record was changed due
382to an edit. The <em>mode</em> parameter is the type of edit that just
383took place.
384
385<h3 class=fn><a href="qt.html#DateFormat-enum">DateFormat</a> <a name="dateFormat"></a>QDataTable::dateFormat () const
386</h3><p>Returns the format used for displaying date/time values.
387See the <a href="qdatatable.html#dateFormat-prop">"dateFormat"</a> property for details.
388<h3 class=fn>bool <a name="deleteCurrent"></a>QDataTable::deleteCurrent ()<tt> [virtual protected]</tt>
389</h3>
390For an editable table, issues a delete on the current cursor's
391primary index using the values of the currently selected row. If
392there is no current cursor or there is no current selection,
393nothing happens. If <a href="#confirmEdits">confirmEdits</a>() or <a href="#confirmDelete">confirmDelete</a>() is TRUE,
394<a href="#confirmEdit">confirmEdit</a>() is called to confirm the delete. Returns TRUE if the
395delete succeeded; otherwise FALSE.
396<p> The underlying cursor must have a valid primary index to ensure
397that a unique record is deleted within the database otherwise the
398database may be changed to an inconsistent state.
399
400<h3 class=fn><a href="qstring.html">QString</a> <a name="falseText"></a>QDataTable::falseText () const
401</h3><p>Returns the text used to represent false values.
402See the <a href="qdatatable.html#falseText-prop">"falseText"</a> property for details.
403<h3 class=fn>int <a name="fieldAlignment"></a>QDataTable::fieldAlignment ( const&nbsp;<a href="qsqlfield.html">QSqlField</a>&nbsp;*&nbsp;field )<tt> [virtual protected]</tt>
404</h3>
405Returns the alignment for <em>field</em>.
406
407<h3 class=fn><a href="qstring.html">QString</a> <a name="filter"></a>QDataTable::filter () const
408</h3><p>Returns the data filter for the data table.
409See the <a href="qdatatable.html#filter-prop">"filter"</a> property for details.
410<h3 class=fn>void <a name="find"></a>QDataTable::find ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;str, bool&nbsp;caseSensitive, bool&nbsp;backwards )<tt> [virtual slot]</tt>
411</h3>
412Searches the current cursor for a cell containing the string <em>str</em> starting at the current cell and working forwards (or
413backwards if <em>backwards</em> is TRUE). If the string is found, the
414cell containing the string is set as the current cell. If <em>caseSensitive</em> is FALSE the case of <em>str</em> will be ignored.
415<p> The search will wrap, i.e. if the first (or if backwards is TRUE,
416last) cell is reached without finding <em>str</em> the search will
417continue until it reaches the starting cell. If <em>str</em> is not
418found the search will fail and the current cell will remain
419unchanged.
420
421<h3 class=fn>void <a name="handleError"></a>QDataTable::handleError ( const&nbsp;<a href="qsqlerror.html">QSqlError</a>&nbsp;&amp;&nbsp;e )<tt> [virtual protected]</tt>
422</h3>
423Protected virtual function which is called when an error <em>e</em> has
424occurred on the current <a href="qwidget.html#cursor">cursor</a>(). The default implementation
425displays a warning message to the user with information about the
426error.
427
428<h3 class=fn>int <a name="indexOf"></a>QDataTable::indexOf ( uint&nbsp;i ) const<tt> [protected]</tt>
429</h3>
430Returns the index of the field within the current SQL query that
431is displayed in column <em>i</em>.
432
433<h3 class=fn>bool <a name="insertCurrent"></a>QDataTable::insertCurrent ()<tt> [virtual protected]</tt>
434</h3>
435For an editable table, issues an insert on the current cursor
436using the values in the cursor's edit buffer. If there is no
437current cursor or there is no current "insert" row, nothing
438happens. If <a href="#confirmEdits">confirmEdits</a>() or <a href="#confirmInsert">confirmInsert</a>() is TRUE,
439<a href="#confirmEdit">confirmEdit</a>() is called to confirm the insert. Returns TRUE if the
440insert succeeded; otherwise returns FALSE.
441<p> The underlying cursor must have a valid primary index to ensure
442that a unique record is inserted within the database otherwise the
443database may be changed to an inconsistent state.
444
445<h3 class=fn>void <a name="installEditorFactory"></a>QDataTable::installEditorFactory ( <a href="qsqleditorfactory.html">QSqlEditorFactory</a>&nbsp;*&nbsp;f )
446</h3>
447Installs a new SQL editor factory <em>f</em>. This enables the user to
448create and instantiate their own editors for use in cell editing.
449Note that QDataTable takes ownership of this pointer, and will
450delete it when it is no longer needed or when
451<a href="#installEditorFactory">installEditorFactory</a>() is called again.
452<p> <p>See also <a href="qsqleditorfactory.html">QSqlEditorFactory</a>.
453
454<h3 class=fn>void <a name="installPropertyMap"></a>QDataTable::installPropertyMap ( <a href="qsqlpropertymap.html">QSqlPropertyMap</a>&nbsp;*&nbsp;m )
455</h3>
456Installs a new property map <em>m</em>. This enables the user to create
457and instantiate their own property maps for use in cell editing.
458Note that QDataTable takes ownership of this pointer, and will
459delete it when it is no longer needed or when installPropertMap()
460is called again.
461<p> <p>See also <a href="qsqlpropertymap.html">QSqlPropertyMap</a>.
462
463<h3 class=fn><a href="qstring.html">QString</a> <a name="nullText"></a>QDataTable::nullText () const
464</h3><p>Returns the text used to represent NULL values.
465See the <a href="qdatatable.html#nullText-prop">"nullText"</a> property for details.
466<h3 class=fn>int <a name="numCols"></a>QDataTable::numCols () const<tt> [virtual]</tt>
467</h3><p>Returns the number of columns in the table.
468See the <a href="qdatatable.html#numCols-prop">"numCols"</a> property for details.
469<p>Reimplemented from <a href="qtable.html#numCols">QTable</a>.
470<h3 class=fn>int <a name="numRows"></a>QDataTable::numRows () const<tt> [virtual]</tt>
471</h3><p>Returns the number of rows in the table.
472See the <a href="qdatatable.html#numRows-prop">"numRows"</a> property for details.
473<p>Reimplemented from <a href="qtable.html#numRows">QTable</a>.
474<h3 class=fn>void <a name="paintField"></a>QDataTable::paintField ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, const&nbsp;<a href="qsqlfield.html">QSqlField</a>&nbsp;*&nbsp;field, const&nbsp;<a href="qrect.html">QRect</a>&nbsp;&amp;&nbsp;cr, bool&nbsp;selected )<tt> [virtual protected]</tt>
475</h3>
476Paints the <em>field</em> on the painter <em>p</em>. The painter has already
477been translated to the appropriate cell's origin where the <em>field</em> is to be rendered. <em>cr</em> describes the cell coordinates in
478the content coordinate system. The <em>selected</em> parameter is
479ignored.
480<p> If you want to draw custom field content you must reimplement
481<a href="#paintField">paintField</a>() to do the custom drawing. The default implementation
482renders the <em>field</em> value as text. If the field is NULL,
483<a href="#nullText">nullText</a>() is displayed in the cell. If the field is Boolean,
484<a href="#trueText">trueText</a>() or <a href="#falseText">falseText</a>() is displayed as appropriate.
485
486<p>Example: <a href="sql.html#x2245">sql/overview/table4/main.cpp</a>.
487<h3 class=fn>void <a name="primeDelete"></a>QDataTable::primeDelete ( <a href="qsqlrecord.html">QSqlRecord</a>&nbsp;*&nbsp;buf )<tt> [signal]</tt>
488</h3>
489
490<p> This signal is emitted after the cursor is primed for delete by
491the table, when a delete action is beginning on the table. The <em>buf</em> parameter points to the edit buffer being deleted. Connect to
492this signal in order to, for example, record auditing information
493on deletions.
494
495<h3 class=fn>void <a name="primeInsert"></a>QDataTable::primeInsert ( <a href="qsqlrecord.html">QSqlRecord</a>&nbsp;*&nbsp;buf )<tt> [signal]</tt>
496</h3>
497
498<p> This signal is emitted after the cursor is primed for insert by
499the table, when an insert action is beginning on the table. The <em>buf</em> parameter points to the edit buffer being inserted. Connect to
500this signal in order to, for example, <a href="primes.html#prime">prime</a> the record buffer with
501default data values.
502
503<h3 class=fn>void <a name="primeUpdate"></a>QDataTable::primeUpdate ( <a href="qsqlrecord.html">QSqlRecord</a>&nbsp;*&nbsp;buf )<tt> [signal]</tt>
504</h3>
505
506<p> This signal is emitted after the cursor is primed for update by
507the table, when an update action is beginning on the table. The <em>buf</em> parameter points to the edit buffer being updated. Connect to
508this signal in order to, for example, provide some visual feedback
509that the user is in 'edit mode'.
510
511<h3 class=fn>void <a name="refresh"></a>QDataTable::refresh ()<tt> [virtual slot]</tt>
512</h3>
513Refreshes the table. The cursor is refreshed using the current
514filter, the current sort, and the currently defined columns.
515Equivalent to calling <a href="#refresh">refresh</a>( QDataTable::RefreshData ).
516
517<p>Examples: <a href="sql.html#x2256">sql/overview/subclass1/main.cpp</a>, <a href="sql.html#x2211">sql/overview/table1/main.cpp</a>, <a href="sql.html#x2215">sql/overview/table2/main.cpp</a>, and <a href="sqltable-example.html#x2452">sql/sqltable/main.cpp</a>.
518<h3 class=fn>void <a name="refresh-2"></a>QDataTable::refresh ( <a href="qdatatable.html#Refresh-enum">Refresh</a>&nbsp;mode )
519</h3>
520This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
521<p> Refreshes the table. If there is no currently defined cursor (see
522<a href="#setSqlCursor">setSqlCursor</a>()), nothing happens. The <em>mode</em> parameter determines
523which type of refresh will take place.
524<p> <p>See also <a href="#Refresh-enum">Refresh</a>, <a href="#setSqlCursor">setSqlCursor</a>(), and <a href="#addColumn">addColumn</a>().
525
526<h3 class=fn>void <a name="removeColumn"></a>QDataTable::removeColumn ( uint&nbsp;col )<tt> [virtual]</tt>
527</h3>
528Removes column <em>col</em> from the list of columns to be displayed. If
529<em>col</em> does not exist, nothing happens.
530<p> <p>See also <a href="qsqlfield.html">QSqlField</a>.
531
532<h3 class=fn>void <a name="reset"></a>QDataTable::reset ()<tt> [protected]</tt>
533</h3>
534Resets the table so that it displays no data.
535<p> <p>See also <a href="#setSqlCursor">setSqlCursor</a>().
536
537<h3 class=fn>void <a name="setAutoDelete"></a>QDataTable::setAutoDelete ( bool&nbsp;enable )<tt> [virtual]</tt>
538</h3>
539Sets the cursor auto-delete flag to <em>enable</em>. If <em>enable</em> is
540TRUE, the table will automatically delete the cursor specified by
541<a href="#setSqlCursor">setSqlCursor</a>(). If <em>enable</em> is FALSE (the default), the cursor
542will not be deleted.
543
544<h3 class=fn>void <a name="setAutoEdit"></a>QDataTable::setAutoEdit ( bool&nbsp;autoEdit )<tt> [virtual]</tt>
545</h3><p>Sets whether the data table automatically applies edits to <em>autoEdit</em>.
546See the <a href="qdatatable.html#autoEdit-prop">"autoEdit"</a> property for details.
547<h3 class=fn>void <a name="setColumn"></a>QDataTable::setColumn ( uint&nbsp;col, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;fieldName, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;label = QString::null, int&nbsp;width = -1, const&nbsp;<a href="qiconset.html">QIconSet</a>&nbsp;&amp;&nbsp;iconset = QIconSet ( ) )<tt> [virtual]</tt>
548</h3>
549Sets the <em>col</em> column to display using the field <em>fieldName</em>,
550column label <em>label</em>, width <em>width</em> and iconset <em>iconset</em>.
551<p> If <em>label</em> is specified, it is used as the column's header label,
552otherwise the field's display label is used when <a href="#setSqlCursor">setSqlCursor</a>() is
553called. The <em>iconset</em> is used to set the icon used by the column
554header; by default there is no icon.
555<p> <p>See also <a href="#setSqlCursor">setSqlCursor</a>() and <a href="#refresh">refresh</a>().
556
557<h3 class=fn>void <a name="setColumnWidth"></a>QDataTable::setColumnWidth ( int&nbsp;col, int&nbsp;w )<tt> [virtual slot]</tt>
558</h3>
559Sets the column <em>col</em> to the width <em>w</em>. Note that unlike <a href="qtable.html">QTable</a>
560the QDataTable is not immediately redrawn, you must call
561<a href="#refresh">refresh</a>(QDataTable::RefreshColumns)
562yourself.
563<p> <p>See also <a href="#refresh">refresh</a>().
564
565<p>Reimplemented from <a href="qtable.html#setColumnWidth">QTable</a>.
566<h3 class=fn>void <a name="setConfirmCancels"></a>QDataTable::setConfirmCancels ( bool&nbsp;confirm )<tt> [virtual]</tt>
567</h3><p>Sets whether the data table confirms cancel operations to <em>confirm</em>.
568See the <a href="qdatatable.html#confirmCancels-prop">"confirmCancels"</a> property for details.
569<h3 class=fn>void <a name="setConfirmDelete"></a>QDataTable::setConfirmDelete ( bool&nbsp;confirm )<tt> [virtual]</tt>
570</h3><p>Sets whether the data table confirms delete operations to <em>confirm</em>.
571See the <a href="qdatatable.html#confirmDelete-prop">"confirmDelete"</a> property for details.
572<h3 class=fn>void <a name="setConfirmEdits"></a>QDataTable::setConfirmEdits ( bool&nbsp;confirm )<tt> [virtual]</tt>
573</h3><p>Sets whether the data table confirms edit operations to <em>confirm</em>.
574See the <a href="qdatatable.html#confirmEdits-prop">"confirmEdits"</a> property for details.
575<h3 class=fn>void <a name="setConfirmInsert"></a>QDataTable::setConfirmInsert ( bool&nbsp;confirm )<tt> [virtual]</tt>
576</h3><p>Sets whether the data table confirms insert operations to <em>confirm</em>.
577See the <a href="qdatatable.html#confirmInsert-prop">"confirmInsert"</a> property for details.
578<h3 class=fn>void <a name="setConfirmUpdate"></a>QDataTable::setConfirmUpdate ( bool&nbsp;confirm )<tt> [virtual]</tt>
579</h3><p>Sets whether the data table confirms update operations to <em>confirm</em>.
580See the <a href="qdatatable.html#confirmUpdate-prop">"confirmUpdate"</a> property for details.
581<h3 class=fn>void <a name="setDateFormat"></a>QDataTable::setDateFormat ( const&nbsp;<a href="qt.html#DateFormat-enum">DateFormat</a>&nbsp;f )<tt> [virtual]</tt>
582</h3><p>Sets the format used for displaying date/time values to <em>f</em>.
583See the <a href="qdatatable.html#dateFormat-prop">"dateFormat"</a> property for details.
584<h3 class=fn>void <a name="setFalseText"></a>QDataTable::setFalseText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;falseText )<tt> [virtual]</tt>
585</h3><p>Sets the text used to represent false values to <em>falseText</em>.
586See the <a href="qdatatable.html#falseText-prop">"falseText"</a> property for details.
587<h3 class=fn>void <a name="setFilter"></a>QDataTable::setFilter ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;filter )<tt> [virtual]</tt>
588</h3><p>Sets the data filter for the data table to <em>filter</em>.
589See the <a href="qdatatable.html#filter-prop">"filter"</a> property for details.
590<h3 class=fn>void <a name="setNullText"></a>QDataTable::setNullText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;nullText )<tt> [virtual]</tt>
591</h3><p>Sets the text used to represent NULL values to <em>nullText</em>.
592See the <a href="qdatatable.html#nullText-prop">"nullText"</a> property for details.
593<h3 class=fn>void <a name="setSize"></a>QDataTable::setSize ( <a href="qsqlcursor.html">QSqlCursor</a>&nbsp;*&nbsp;sql )<tt> [protected]</tt>
594</h3>
595If the cursor's <em>sql</em> driver supports query sizes, the number of
596rows in the table is set to the size of the query. Otherwise, the
597table dynamically resizes itself as it is scrolled. If <em>sql</em> is
598not active, it is made active by issuing a select() on the cursor
599using the <em>sql</em> cursor's current filter and current sort.
600
601<h3 class=fn>void <a name="setSort"></a>QDataTable::setSort ( const&nbsp;<a href="qstringlist.html">QStringList</a>&nbsp;&amp;&nbsp;sort )<tt> [virtual]</tt>
602</h3><p>Sets the data table's sort to <em>sort</em>.
603See the <a href="qdatatable.html#sort-prop">"sort"</a> property for details.
604<h3 class=fn>void <a name="setSort-2"></a>QDataTable::setSort ( const&nbsp;<a href="qsqlindex.html">QSqlIndex</a>&nbsp;&amp;&nbsp;sort )<tt> [virtual]</tt>
605</h3>
606This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
607<p> Sets the sort to be applied to the displayed data to <em>sort</em>. If
608there is no current cursor, nothing happens. A <a href="qsqlindex.html">QSqlIndex</a> contains
609field names and their ordering (ASC or DESC); these are used to
610compose the ORDER BY clause.
611<p> <p>See also <a href="#sort-prop">sort</a>.
612
613<h3 class=fn>void <a name="setSqlCursor"></a>QDataTable::setSqlCursor ( <a href="qsqlcursor.html">QSqlCursor</a>&nbsp;*&nbsp;cursor = 0, bool&nbsp;autoPopulate = FALSE, bool&nbsp;autoDelete = FALSE )<tt> [virtual]</tt>
614</h3>
615Sets <em>cursor</em> as the data source for the table. To force the
616display of the data from <em>cursor</em>, use <a href="#refresh">refresh</a>(). If <em>autoPopulate</em> is TRUE, columns are automatically created based upon
617the fields in the <em>cursor</em> record. If <em>autoDelete</em> is TRUE (the
618default is FALSE), the table will take ownership of the <em>cursor</em>
619and delete it when appropriate. If the <em>cursor</em> is read-only, the
620table becomes read-only. The table adopts the cursor's driver's
621definition for representing NULL values as strings.
622<p> <p>See also <a href="#refresh">refresh</a>(), <a href="qtable.html#readOnly-prop">readOnly</a>, <a href="#setAutoDelete">setAutoDelete</a>(), and <a href="qsqldriver.html#nullText">QSqlDriver::nullText</a>().
623
624<h3 class=fn>void <a name="setTrueText"></a>QDataTable::setTrueText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;trueText )<tt> [virtual]</tt>
625</h3><p>Sets the text used to represent true values to <em>trueText</em>.
626See the <a href="qdatatable.html#trueText-prop">"trueText"</a> property for details.
627<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="sort"></a>QDataTable::sort () const
628</h3><p>Returns the data table's sort.
629See the <a href="qdatatable.html#sort-prop">"sort"</a> property for details.
630<h3 class=fn>void <a name="sortAscending"></a>QDataTable::sortAscending ( int&nbsp;col )<tt> [virtual slot]</tt>
631</h3>
632Sorts column <em>col</em> in ascending order.
633<p> <p>See also <a href="qtable.html#sorting-prop">sorting</a>.
634
635<h3 class=fn>void <a name="sortColumn"></a>QDataTable::sortColumn ( int&nbsp;col, bool&nbsp;ascending = TRUE, bool&nbsp;wholeRows = FALSE )<tt> [virtual]</tt>
636</h3>
637Sorts column <em>col</em> in ascending order if <em>ascending</em> is TRUE
638(the default); otherwise sorts in descending order.
639<p> The <em>wholeRows</em> parameter is ignored; QDataTable always sorts
640whole rows by the specified column.
641
642<p>Reimplemented from <a href="qtable.html#sortColumn">QTable</a>.
643<h3 class=fn>void <a name="sortDescending"></a>QDataTable::sortDescending ( int&nbsp;col )<tt> [virtual slot]</tt>
644</h3>
645Sorts column <em>col</em> in descending order.
646<p> <p>See also <a href="qtable.html#sorting-prop">sorting</a>.
647
648<h3 class=fn><a href="qsqlcursor.html">QSqlCursor</a>&nbsp;* <a name="sqlCursor"></a>QDataTable::sqlCursor () const
649</h3>
650Returns the cursor used by the data table.
651
652<h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QDataTable::text ( int&nbsp;row, int&nbsp;col ) const<tt> [virtual]</tt>
653</h3>
654Returns the text in cell <em>row</em>, <em>col</em>, or an empty string if the
655cell is empty. If the cell's value is NULL then <a href="#nullText">nullText</a>() will be
656returned. If the cell does not exist then <a href="qstring.html#QString-null">QString::null</a> is
657returned.
658
659<p>Reimplemented from <a href="qtable.html#text">QTable</a>.
660<h3 class=fn><a href="qstring.html">QString</a> <a name="trueText"></a>QDataTable::trueText () const
661</h3><p>Returns the text used to represent true values.
662See the <a href="qdatatable.html#trueText-prop">"trueText"</a> property for details.
663<h3 class=fn>bool <a name="updateCurrent"></a>QDataTable::updateCurrent ()<tt> [virtual protected]</tt>
664</h3>
665For an editable table, issues an update using the cursor's edit
666buffer. If there is no current cursor or there is no current
667selection, nothing happens. If <a href="#confirmEdits">confirmEdits</a>() or <a href="#confirmUpdate">confirmUpdate</a>()
668is TRUE, <a href="#confirmEdit">confirmEdit</a>() is called to confirm the update. Returns
669TRUE if the update succeeded; otherwise returns FALSE.
670<p> The underlying cursor must have a valid primary index to ensure
671that a unique record is updated within the database otherwise the
672database may be changed to an inconsistent state.
673
674<h3 class=fn><a href="qvariant.html">QVariant</a> <a name="value"></a>QDataTable::value ( int&nbsp;row, int&nbsp;col ) const
675</h3>
676Returns the value in cell <em>row</em>, <em>col</em>, or an invalid value if
677the cell does not exist or has no value.
678
679<hr><h2>Property Documentation</h2>
680<h3 class=fn>bool <a name="autoEdit-prop"></a>autoEdit</h3>
681<p>This property holds whether the data table automatically applies edits.
682<p>The default value for this property is TRUE. When the user begins
683an insert or update in the table there are two possible outcomes
684when they navigate to another record:
685<p> <ol type=1>
686<li> the insert or update is is performed -- this occurs if autoEdit is TRUE
687<li> the insert or update is abandoned -- this occurs if autoEdit is FALSE
688</ol>
689
690<p>Set this property's value with <a href="#setAutoEdit">setAutoEdit</a>() and get this property's value with <a href="#autoEdit">autoEdit</a>().
691<h3 class=fn>bool <a name="confirmCancels-prop"></a>confirmCancels</h3>
692<p>This property holds whether the data table confirms cancel operations.
693<p>If the confirmCancel property is TRUE, all cancels must be
694confirmed by the user through a message box (this behavior can be
695changed by overriding the <a href="#confirmCancel">confirmCancel</a>() function), otherwise all
696cancels occur immediately. The default is FALSE.
697<p> <p>See also <a href="#confirmEdits-prop">confirmEdits</a> and <a href="#confirmCancel">confirmCancel</a>().
698
699<p>Set this property's value with <a href="#setConfirmCancels">setConfirmCancels</a>() and get this property's value with <a href="#confirmCancels">confirmCancels</a>().
700<h3 class=fn>bool <a name="confirmDelete-prop"></a>confirmDelete</h3>
701<p>This property holds whether the data table confirms delete operations.
702<p>If the confirmDelete property is TRUE, all deletions must be
703confirmed by the user through a message box (this behaviour can be
704changed by overriding the <a href="#confirmEdit">confirmEdit</a>() function), otherwise all
705delete operations occur immediately.
706<p> <p>See also <a href="#confirmCancels-prop">confirmCancels</a>, <a href="#confirmEdits-prop">confirmEdits</a>, <a href="#confirmUpdate-prop">confirmUpdate</a>, and <a href="#confirmInsert-prop">confirmInsert</a>.
707
708<p>Set this property's value with <a href="#setConfirmDelete">setConfirmDelete</a>() and get this property's value with <a href="#confirmDelete">confirmDelete</a>().
709<h3 class=fn>bool <a name="confirmEdits-prop"></a>confirmEdits</h3>
710<p>This property holds whether the data table confirms edit operations.
711<p>If the confirmEdits property is TRUE, the data table confirms all
712edit operations (inserts, updates and deletes). Finer control of
713edit confirmation can be achieved using <a href="#confirmCancels-prop">confirmCancels</a>, <a href="#confirmInsert-prop">confirmInsert</a>, <a href="#confirmUpdate-prop">confirmUpdate</a> and <a href="#confirmDelete-prop">confirmDelete</a>.
714<p> <p>See also <a href="#confirmCancels-prop">confirmCancels</a>, <a href="#confirmInsert-prop">confirmInsert</a>, <a href="#confirmUpdate-prop">confirmUpdate</a>, and <a href="#confirmDelete-prop">confirmDelete</a>.
715
716<p>Set this property's value with <a href="#setConfirmEdits">setConfirmEdits</a>() and get this property's value with <a href="#confirmEdits">confirmEdits</a>().
717<h3 class=fn>bool <a name="confirmInsert-prop"></a>confirmInsert</h3>
718<p>This property holds whether the data table confirms insert operations.
719<p>If the confirmInsert property is TRUE, all insertions must be
720confirmed by the user through a message box (this behaviour can be
721changed by overriding the <a href="#confirmEdit">confirmEdit</a>() function), otherwise all
722insert operations occur immediately.
723<p> <p>See also <a href="#confirmCancels-prop">confirmCancels</a>, <a href="#confirmEdits-prop">confirmEdits</a>, <a href="#confirmUpdate-prop">confirmUpdate</a>, and <a href="#confirmDelete-prop">confirmDelete</a>.
724
725<p>Set this property's value with <a href="#setConfirmInsert">setConfirmInsert</a>() and get this property's value with <a href="#confirmInsert">confirmInsert</a>().
726<h3 class=fn>bool <a name="confirmUpdate-prop"></a>confirmUpdate</h3>
727<p>This property holds whether the data table confirms update operations.
728<p>If the confirmUpdate property is TRUE, all updates must be
729confirmed by the user through a message box (this behaviour can be
730changed by overriding the <a href="#confirmEdit">confirmEdit</a>() function), otherwise all
731update operations occur immediately.
732<p> <p>See also <a href="#confirmCancels-prop">confirmCancels</a>, <a href="#confirmEdits-prop">confirmEdits</a>, <a href="#confirmInsert-prop">confirmInsert</a>, and <a href="#confirmDelete-prop">confirmDelete</a>.
733
734<p>Set this property's value with <a href="#setConfirmUpdate">setConfirmUpdate</a>() and get this property's value with <a href="#confirmUpdate">confirmUpdate</a>().
735<h3 class=fn><a href="qt.html#DateFormat-enum">DateFormat</a> <a name="dateFormat-prop"></a>dateFormat</h3>
736<p>This property holds the format used for displaying date/time values.
737<p>The dateFormat property is used for displaying date/time values in
738the table. The default value is <a href="qt.html#DateFormat-enum">Qt::LocalDate</a>.
739
740<p>Set this property's value with <a href="#setDateFormat">setDateFormat</a>() and get this property's value with <a href="#dateFormat">dateFormat</a>().
741<h3 class=fn><a href="qstring.html">QString</a> <a name="falseText-prop"></a>falseText</h3>
742<p>This property holds the text used to represent false values.
743<p>The falseText property will be used to represent NULL values in
744the table. The default value is "False".
745
746<p>Set this property's value with <a href="#setFalseText">setFalseText</a>() and get this property's value with <a href="#falseText">falseText</a>().
747<h3 class=fn><a href="qstring.html">QString</a> <a name="filter-prop"></a>filter</h3>
748<p>This property holds the data filter for the data table.
749<p>The filter applies to the data shown in the table. To view data
750with a new filter, use <a href="#refresh">refresh</a>(). A filter string is an SQL WHERE
751clause without the WHERE keyword.
752<p> There is no default filter.
753<p> <p>See also <a href="#sort-prop">sort</a>.
754
755<p>
756<p>Set this property's value with <a href="#setFilter">setFilter</a>() and get this property's value with <a href="#filter">filter</a>().
757<h3 class=fn><a href="qstring.html">QString</a> <a name="nullText-prop"></a>nullText</h3>
758<p>This property holds the text used to represent NULL values.
759<p>The nullText property will be used to represent NULL values in the
760table. The default value is provided by the cursor's driver.
761
762<p>Set this property's value with <a href="#setNullText">setNullText</a>() and get this property's value with <a href="#nullText">nullText</a>().
763<h3 class=fn>int <a name="numCols-prop"></a>numCols</h3>
764<p>This property holds the number of columns in the table.
765<p>
766<p>Get this property's value with <a href="#numCols">numCols</a>().
767<h3 class=fn>int <a name="numRows-prop"></a>numRows</h3>
768<p>This property holds the number of rows in the table.
769<p>
770<p>Get this property's value with <a href="#numRows">numRows</a>().
771<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="sort-prop"></a>sort</h3>
772<p>This property holds the data table's sort.
773<p>The table's sort affects the order in which data records are
774displayed in the table. To apply a sort, use <a href="#refresh">refresh</a>().
775<p> When examining the sort property, a string list is returned with
776each item having the form 'fieldname order' (e.g., 'id ASC',
777'surname DESC').
778<p> There is no default sort.
779<p> Note that if you want to iterate over the sort list, you should
780iterate over a copy, e.g.
781<pre>
782 <a href="qstringlist.html">QStringList</a> list = myDataTable.sort();
783 QStringList::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>();
784 while( it != list.<a href="qvaluelist.html#end">end</a>() ) {
785 myProcessing( *it );
786 ++it;
787 }
788 </pre>
789
790<p> <p>See also <a href="#filter-prop">filter</a> and <a href="#refresh">refresh</a>().
791
792<p>Set this property's value with <a href="#setSort">setSort</a>() and get this property's value with <a href="#sort">sort</a>().
793<h3 class=fn><a href="qstring.html">QString</a> <a name="trueText-prop"></a>trueText</h3>
794<p>This property holds the text used to represent true values.
795<p>The trueText property will be used to represent NULL values in the
796table. The default value is "True".
797
798<p>Set this property's value with <a href="#setTrueText">setTrueText</a>() and get this property's value with <a href="#trueText">trueText</a>().
799<!-- eof -->
800<hr><p>
801This file is part of the <a href="index.html">Qt toolkit</a>.
802Copyright &copy; 1995-2007
803<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
804<table width=100% cellspacing=0 border=0><tr>
805<td>Copyright &copy; 2007
806<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
807<td align=right><div align=right>Qt 3.3.8</div>
808</table></div></address></body>
809</html>
Note: See TracBrowser for help on using the repository browser.