1QDataTable(3qt)                                                QDataTable(3qt)
2
3
4

NAME

6       QDataTable - Flexible SQL table widget that supports browsing and
7       editing
8

SYNOPSIS

10       #include <qdatatable.h>
11
12       Inherits QTable.
13
14   Public Members
15       QDataTable ( QWidget * parent = 0, const char * name = 0 )
16       QDataTable ( QSqlCursor * cursor, bool autoPopulate = FALSE, QWidget *
17           parent = 0, const char * name = 0 )
18       ~QDataTable ()
19       virtual void addColumn ( const QString & fieldName, const QString &
20           label = QString::null, int width = -1, const QIconSet & iconset =
21           QIconSet ( ) )
22       virtual void removeColumn ( uint col )
23       virtual void setColumn ( uint col, const QString & fieldName, const
24           QString & label = QString::null, int width = -1, const QIconSet &
25           iconset = QIconSet ( ) )
26       QString nullText () const
27       QString trueText () const
28       QString falseText () const
29       DateFormat dateFormat () const
30       bool confirmEdits () const
31       bool confirmInsert () const
32       bool confirmUpdate () const
33       bool confirmDelete () const
34       bool confirmCancels () const
35       bool autoDelete () const
36       bool autoEdit () const
37       QString filter () const
38       QStringList sort () const
39       virtual void setSqlCursor ( QSqlCursor * cursor = 0, bool autoPopulate
40           = FALSE, bool autoDelete = FALSE )
41       QSqlCursor * sqlCursor () const
42       virtual void setNullText ( const QString & nullText )
43       virtual void setTrueText ( const QString & trueText )
44       virtual void setFalseText ( const QString & falseText )
45       virtual void setDateFormat ( const DateFormat f )
46       virtual void setConfirmEdits ( bool confirm )
47       virtual void setConfirmInsert ( bool confirm )
48       virtual void setConfirmUpdate ( bool confirm )
49       virtual void setConfirmDelete ( bool confirm )
50       virtual void setConfirmCancels ( bool confirm )
51       virtual void setAutoDelete ( bool enable )
52       virtual void setAutoEdit ( bool autoEdit )
53       virtual void setFilter ( const QString & filter )
54       virtual void setSort ( const QStringList & sort )
55       virtual void setSort ( const QSqlIndex & sort )
56       enum Refresh { RefreshData = 1, RefreshColumns = 2, RefreshAll = 3 }
57       void refresh ( Refresh mode )
58       virtual void sortColumn ( int col, bool ascending = TRUE, bool
59           wholeRows = FALSE )
60       virtual QString text ( int row, int col ) const
61       QVariant value ( int row, int col ) const
62       QSqlRecord * currentRecord () const
63       void installEditorFactory ( QSqlEditorFactory * f )
64       void installPropertyMap ( QSqlPropertyMap * m )
65       virtual int numCols () const
66       virtual int numRows () const
67
68   Public Slots
69       virtual void find ( const QString & str, bool caseSensitive, bool
70           backwards )
71       virtual void sortAscending ( int col )
72       virtual void sortDescending ( int col )
73       virtual void refresh ()
74       virtual void setColumnWidth ( int col, int w )
75       virtual void adjustColumn ( int col )
76
77   Signals
78       void currentChanged ( QSqlRecord * record )
79       void primeInsert ( QSqlRecord * buf )
80       void primeUpdate ( QSqlRecord * buf )
81       void primeDelete ( QSqlRecord * buf )
82       void beforeInsert ( QSqlRecord * buf )
83       void beforeUpdate ( QSqlRecord * buf )
84       void beforeDelete ( QSqlRecord * buf )
85       void cursorChanged ( QSql::Op mode )
86
87   Properties
88       bool autoEdit - whether the data table automatically applies edits
89       bool confirmCancels - whether the data table confirms cancel operations
90       bool confirmDelete - whether the data table confirms delete operations
91       bool confirmEdits - whether the data table confirms edit operations
92       bool confirmInsert - whether the data table confirms insert operations
93       bool confirmUpdate - whether the data table confirms update operations
94       DateFormat dateFormat - the format used for displaying date/time values
95       QString falseText - the text used to represent false values
96       QString filter - the data filter for the data table
97       QString nullText - the text used to represent NULL values
98       int numCols - the number of columns in the table  (read only)
99       int numRows - the number of rows in the table  (read only)
100       QStringList sort - the data table's sort
101       QString trueText - the text used to represent true values
102
103   Protected Members
104       virtual bool insertCurrent ()
105       virtual bool updateCurrent ()
106       virtual bool deleteCurrent ()
107       virtual QSql::Confirm confirmEdit ( QSql::Op m )
108       virtual QSql::Confirm confirmCancel ( QSql::Op m )
109       virtual void handleError ( const QSqlError & e )
110       virtual bool beginInsert ()
111       virtual QWidget * beginUpdate ( int row, int col, bool replace )
112       int indexOf ( uint i ) const
113       void reset ()
114       void setSize ( QSqlCursor * sql )
115       virtual void paintField ( QPainter * p, const QSqlField * field, const
116           QRect & cr, bool selected )
117       virtual int fieldAlignment ( const QSqlField * field )
118

DESCRIPTION

120       The QDataTable class provides a flexible SQL table widget that supports
121       browsing and editing.
122
123       QDataTable supports various functions for presenting and editing SQL
124       data from a QSqlCursor in a table.
125
126       If you want a to present your data in a form use QDataBrowser, or for
127       read-only forms, QDataView.
128
129       When displaying data, QDataTable only retrieves data for visible rows.
130       If the driver supports the 'query size' property the QDataTable will
131       have the correct number of rows and the vertical scrollbar will
132       accurately reflect the number of rows displayed in proportion to the
133       number of rows in the dataset. If the driver does not support the
134       'query size' property, rows are dynamically fetched from the database
135       on an as-needed basis with the scrollbar becoming more accurate as the
136       user scrolls down through the records. This allows extremely large
137       queries to be displayed as quickly as possible, with minimum memory
138       usage.
139
140       QDataTable inherits QTable's API and extends it with functions to sort
141       and filter the data and sort columns. See setSqlCursor(), setFilter(),
142       setSort(), setSorting(), sortColumn() and refresh().
143
144       When displaying editable cursors, cell editing will be enabled. (For
145       more information on editable cursors, see QSqlCursor). QDataTable can
146       be used to modify existing data and to add new records. When a user
147       makes changes to a field in the table, the cursor's edit buffer is
148       used. The table will not send changes in the edit buffer to the
149       database until the user moves to a different record in the grid or
150       presses Enter. Cell editing is initiated by pressing F2 (or right
151       clicking and then clicking the appropriate popup menu item) and
152       canceled by pressing Esc. If there is a problem updating or adding
153       data, errors are handled automatically (see handleError() to change
154       this behavior). Note that if autoEdit() is FALSE navigating to another
155       record will cancel the insert or update.
156
157       The user can be asked to confirm all edits with setConfirmEdits(). For
158       more precise control use setConfirmInsert(), setConfirmUpdate(),
159       setConfirmDelete() and setConfirmCancels(). Use setAutoEdit() to
160       control the behaviour of the table when the user edits a record and
161       then navigates. (Note that setAutoDelete() is unrelated; it is used to
162       set whether the QSqlCursor is deleted when the table is deleted.)
163
164       Since the data table can perform edits, it must be able to uniquely
165       identify every record so that edits are correctly applied. Because of
166       this the underlying cursor must have a valid primary index to ensure
167       that a unique record is inserted, updated or deleted within the
168       database otherwise the database may be changed to an inconsistent
169       state.
170
171       QDataTable creates editors using the default QSqlEditorFactory.
172       Different editor factories can be used by calling
173       installEditorFactory(). A property map is used to map between the
174       cell's value and the editor. You can use your own property map with
175       installPropertyMap().
176
177       The contents of a cell is available as a QString with text() or as a
178       QVariant with value(). The current record is returned by
179       currentRecord(). Use the find() function to search for a string in the
180       table.
181
182       Editing actions can be applied programatically. For example, the
183       insertCurrent() function reads the fields from the current record into
184       the cursor and performs the insert. The updateCurrent() and
185       deleteCurrent() functions perform similarly to update and delete the
186       current record respectively.
187
188       Columns in the table can be created automatically based on the cursor
189       (see setSqlCursor()). Columns can be manipulated manually using
190       addColumn(), removeColumn() and setColumn().
191
192       The table automatically copies many of the properties of the cursor to
193       format the display of data within cells (alignment, visibility, etc.).
194       The cursor can be changed with setSqlCursor(). The filter (see
195       setFilter()) and sort defined within the table are used instead of the
196       filter and sort set on the cursor. For sorting options see setSort(),
197       sortColumn(), sortAscending() and sortDescending(). Note that sorting
198       operations will not behave as expected if you are using a
199       QSqlSelectCursor because it uses user-defined SQL queries to obtain
200       data.
201
202       The text used to represent NULL, TRUE and FALSE values can be changed
203       with setNullText(), setTrueText() and setFalseText() respectively. You
204       can change the appearance of cells by reimplementing paintField().
205
206       Whenever a new row is selected in the table the currentChanged() signal
207       is emitted. The primeInsert() signal is emitted when an insert is
208       initiated. The primeUpdate() and primeDelete() signals are emitted when
209       update and deletion are initiated respectively. Just before the
210       database is updated a signal is emitted; beforeInsert(), beforeUpdate()
211       or beforeDelete() as appropriate.
212
213       See also Database Classes.
214
215   Member Type Documentation

QDataTable::Refresh

217       This enum describes the refresh options.
218
219       QDataTable::RefreshData - refresh the data, i.e. read it from the
220       database
221
222       QDataTable::RefreshColumns - refresh the list of fields, e.g. the
223       column headings
224
225       QDataTable::RefreshAll - refresh both the data and the list of fields
226

MEMBER FUNCTION DOCUMENTATION

QDataTable::QDataTable ( QWidget * parent = 0, const char * name = 0 )

229       Constructs a data table which is a child of parent, called name name.
230

QDataTable::QDataTable ( QSqlCursor * cursor, bool autoPopulate = FALSE,

232       QWidget * parent = 0, const char * name = 0 )
233       Constructs a data table which is a child of parent, called name name
234       using the cursor cursor.
235
236       If autoPopulate is TRUE (the default is FALSE), columns are
237       automatically created based upon the fields in the cursor record. Note
238       that autoPopulate only governs the creation of columns; to load the
239       cursor's data into the table use refresh().
240
241       If the cursor is read-only, the table also becomes read-only. In
242       addition, the table adopts the cursor's driver's definition for
243       representing NULL values as strings.
244

QDataTable::~QDataTable ()

246       Destroys the object and frees any allocated resources.
247

void QDataTable::addColumn ( const QString & fieldName, const QString & label

249       = QString::null, int width = -1, const QIconSet & iconset = QIconSet (
250       ) ) [virtual]
251       Adds the next column to be displayed using the field fieldName, column
252       label label, width width and iconset iconset.
253
254       If label is specified, it is used as the column's header label,
255       otherwise the field's display label is used when setSqlCursor() is
256       called. The iconset is used to set the icon used by the column header;
257       by default there is no icon.
258
259       See also setSqlCursor() and refresh().
260
261       Examples:
262

void QDataTable::adjustColumn ( int col ) [virtual slot]

264       Resizes column col so that the column width is wide enough to display
265       the widest item the column contains (including the column label). If
266       the table's QSqlCursor is not currently active, the cursor will be
267       refreshed before the column width is calculated. Be aware that this
268       function may be slow on tables that contain large result sets.
269
270       Reimplemented from QTable.
271

bool QDataTable::autoDelete () const

273       Returns TRUE if the table will automatically delete the cursor
274       specified by setSqlCursor(); otherwise returns FALSE.
275

bool QDataTable::autoEdit () const

277       Returns TRUE if the data table automatically applies edits; otherwise
278       returns FALSE. See the "autoEdit" property for details.
279

void QDataTable::beforeDelete ( QSqlRecord * buf ) [signal]

281       This signal is emitted just before the currently selected record is
282       deleted from the database. The buf parameter points to the edit buffer
283       being deleted. Connect to this signal to, for example, copy some of the
284       fields for later use.
285

void QDataTable::beforeInsert ( QSqlRecord * buf ) [signal]

287       This signal is emitted just before the cursor's edit buffer is inserted
288       into the database. The buf parameter points to the edit buffer being
289       inserted. Connect to this signal to, for example, populate a key field
290       with a unique sequence number.
291

void QDataTable::beforeUpdate ( QSqlRecord * buf ) [signal]

293       This signal is emitted just before the cursor's edit buffer is updated
294       in the database. The buf parameter points to the edit buffer being
295       updated. Connect to this signal when you want to transform the user's
296       data behind-the-scenes.
297

bool QDataTable::beginInsert () [virtual protected]

299       Protected virtual function called when editing is about to begin on a
300       new record. If the table is read-only, or if there's no cursor or the
301       cursor does not allow inserts, nothing happens.
302
303       Editing takes place using the cursor's edit buffer(see
304       QSqlCursor::editBuffer()).
305
306       When editing begins, a new row is created in the table marked with an
307       asterisk '*' in the row's vertical header column, i.e. at the left of
308       the row.
309

QWidget * QDataTable::beginUpdate ( int row, int col, bool replace ) [virtual

311       protected]
312       Protected virtual function called when editing is about to begin on an
313       existing row. If the table is read-only, or if there's no cursor,
314       nothing happens.
315
316       Editing takes place using the cursor's edit buffer (see
317       QSqlCursor::editBuffer()).
318
319       row and col refer to the row and column in the QDataTable.
320
321       (replace is provided for reimplementors and reflects the API of
322       QTable::beginEdit().)
323

QSql::Confirm QDataTable::confirmCancel ( QSql::Op m ) [virtual protected]

325       Protected virtual function which returns a confirmation for cancelling
326       an edit mode of m. Derived classes can reimplement this function to
327       provide their own cancel dialog. The default implementation uses a
328       message box which prompts the user to confirm the cancel.
329

bool QDataTable::confirmCancels () const

331       Returns TRUE if the data table confirms cancel operations; otherwise
332       returns FALSE. See the "confirmCancels" property for details.
333

bool QDataTable::confirmDelete () const

335       Returns TRUE if the data table confirms delete operations; otherwise
336       returns FALSE. See the "confirmDelete" property for details.
337

QSql::Confirm QDataTable::confirmEdit ( QSql::Op m ) [virtual protected]

339       Protected virtual function which returns a confirmation for an edit of
340       mode m. Derived classes can reimplement this function to provide their
341       own confirmation dialog. The default implementation uses a message box
342       which prompts the user to confirm the edit action.
343

bool QDataTable::confirmEdits () const

345       Returns TRUE if the data table confirms edit operations; otherwise
346       returns FALSE. See the "confirmEdits" property for details.
347

bool QDataTable::confirmInsert () const

349       Returns TRUE if the data table confirms insert operations; otherwise
350       returns FALSE. See the "confirmInsert" property for details.
351

bool QDataTable::confirmUpdate () const

353       Returns TRUE if the data table confirms update operations; otherwise
354       returns FALSE. See the "confirmUpdate" property for details.
355

void QDataTable::currentChanged ( QSqlRecord * record ) [signal]

357       This signal is emitted whenever a new row is selected in the table. The
358       record parameter points to the contents of the newly selected record.
359

QSqlRecord * QDataTable::currentRecord () const

361       Returns the currently selected record, or 0 if there is no current
362       selection. The table owns the pointer, so do not delete it or otherwise
363       modify it or the cursor it points to.
364

void QDataTable::cursorChanged ( QSql::Op mode ) [signal]

366       This signal is emitted whenever the cursor record was changed due to an
367       edit. The mode parameter is the type of edit that just took place.
368

DateFormat QDataTable::dateFormat () const

370       Returns the format used for displaying date/time values. See the
371       "dateFormat" property for details.
372

bool QDataTable::deleteCurrent () [virtual protected]

374       For an editable table, issues a delete on the current cursor's primary
375       index using the values of the currently selected row. If there is no
376       current cursor or there is no current selection, nothing happens. If
377       confirmEdits() or confirmDelete() is TRUE, confirmEdit() is called to
378       confirm the delete. Returns TRUE if the delete succeeded; otherwise
379       FALSE.
380
381       The underlying cursor must have a valid primary index to ensure that a
382       unique record is deleted within the database otherwise the database may
383       be changed to an inconsistent state.
384

QString QDataTable::falseText () const

386       Returns the text used to represent false values. See the "falseText"
387       property for details.
388

int QDataTable::fieldAlignment ( const QSqlField * field ) [virtual protected]

390
391       Returns the alignment for field.
392

QString QDataTable::filter () const

394       Returns the data filter for the data table. See the "filter" property
395       for details.
396

void QDataTable::find ( const QString & str, bool caseSensitive, bool

398       backwards ) [virtual slot]
399       Searches the current cursor for a cell containing the string str
400       starting at the current cell and working forwards (or backwards if
401       backwards is TRUE). If the string is found, the cell containing the
402       string is set as the current cell. If caseSensitive is FALSE the case
403       of str will be ignored.
404
405       The search will wrap, i.e. if the first (or if backwards is TRUE, last)
406       cell is reached without finding str the search will continue until it
407       reaches the starting cell. If str is not found the search will fail and
408       the current cell will remain unchanged.
409

void QDataTable::handleError ( const QSqlError & e ) [virtual protected]

411       Protected virtual function which is called when an error e has occurred
412       on the current cursor(). The default implementation displays a warning
413       message to the user with information about the error.
414

int QDataTable::indexOf ( uint i ) const [protected]

416       Returns the index of the field within the current SQL query that is
417       displayed in column i.
418

bool QDataTable::insertCurrent () [virtual protected]

420       For an editable table, issues an insert on the current cursor using the
421       values in the cursor's edit buffer. If there is no current cursor or
422       there is no current "insert" row, nothing happens. If confirmEdits() or
423       confirmInsert() is TRUE, confirmEdit() is called to confirm the insert.
424       Returns TRUE if the insert succeeded; otherwise returns FALSE.
425
426       The underlying cursor must have a valid primary index to ensure that a
427       unique record is inserted within the database otherwise the database
428       may be changed to an inconsistent state.
429

void QDataTable::installEditorFactory ( QSqlEditorFactory * f )

431       Installs a new SQL editor factory f. This enables the user to create
432       and instantiate their own editors for use in cell editing. Note that
433       QDataTable takes ownership of this pointer, and will delete it when it
434       is no longer needed or when installEditorFactory() is called again.
435
436       See also QSqlEditorFactory.
437

void QDataTable::installPropertyMap ( QSqlPropertyMap * m )

439       Installs a new property map m. This enables the user to create and
440       instantiate their own property maps for use in cell editing. Note that
441       QDataTable takes ownership of this pointer, and will delete it when it
442       is no longer needed or when installPropertMap() is called again.
443
444       See also QSqlPropertyMap.
445

QString QDataTable::nullText () const

447       Returns the text used to represent NULL values. See the "nullText"
448       property for details.
449

int QDataTable::numCols () const [virtual]

451       Returns the number of columns in the table. See the "numCols" property
452       for details.
453
454       Reimplemented from QTable.
455

int QDataTable::numRows () const [virtual]

457       Returns the number of rows in the table. See the "numRows" property for
458       details.
459
460       Reimplemented from QTable.
461

void QDataTable::paintField ( QPainter * p, const QSqlField * field, const

463       QRect & cr, bool selected ) [virtual protected]
464       Paints the field on the painter p. The painter has already been
465       translated to the appropriate cell's origin where the field is to be
466       rendered. cr describes the cell coordinates in the content coordinate
467       system. The selected parameter is ignored.
468
469       If you want to draw custom field content you must reimplement
470       paintField() to do the custom drawing. The default implementation
471       renders the field value as text. If the field is NULL, nullText() is
472       displayed in the cell. If the field is Boolean, trueText() or
473       falseText() is displayed as appropriate.
474
475       Example: sql/overview/table4/main.cpp.
476

void QDataTable::primeDelete ( QSqlRecord * buf ) [signal]

478       This signal is emitted after the cursor is primed for delete by the
479       table, when a delete action is beginning on the table. The buf
480       parameter points to the edit buffer being deleted. Connect to this
481       signal in order to, for example, record auditing information on
482       deletions.
483

void QDataTable::primeInsert ( QSqlRecord * buf ) [signal]

485       This signal is emitted after the cursor is primed for insert by the
486       table, when an insert action is beginning on the table. The buf
487       parameter points to the edit buffer being inserted. Connect to this
488       signal in order to, for example, prime the record buffer with default
489       data values.
490

void QDataTable::primeUpdate ( QSqlRecord * buf ) [signal]

492       This signal is emitted after the cursor is primed for update by the
493       table, when an update action is beginning on the table. The buf
494       parameter points to the edit buffer being updated. Connect to this
495       signal in order to, for example, provide some visual feedback that the
496       user is in 'edit mode'.
497

void QDataTable::refresh () [virtual slot]

499       Refreshes the table. The cursor is refreshed using the current filter,
500       the current sort, and the currently defined columns. Equivalent to
501       calling refresh( QDataTable::RefreshData ).
502
503       Examples:
504

void QDataTable::refresh ( Refresh mode )

506       This is an overloaded member function, provided for convenience. It
507       behaves essentially like the above function.
508
509       Refreshes the table. If there is no currently defined cursor (see
510       setSqlCursor()), nothing happens. The mode parameter determines which
511       type of refresh will take place.
512
513       See also Refresh, setSqlCursor(), and addColumn().
514

void QDataTable::removeColumn ( uint col ) [virtual]

516       Removes column col from the list of columns to be displayed. If col
517       does not exist, nothing happens.
518
519       See also QSqlField.
520

void QDataTable::reset () [protected]

522       Resets the table so that it displays no data.
523
524       See also setSqlCursor().
525

void QDataTable::setAutoDelete ( bool enable ) [virtual]

527       Sets the cursor auto-delete flag to enable. If enable is TRUE, the
528       table will automatically delete the cursor specified by setSqlCursor().
529       If enable is FALSE (the default), the cursor will not be deleted.
530

void QDataTable::setAutoEdit ( bool autoEdit ) [virtual]

532       Sets whether the data table automatically applies edits to autoEdit.
533       See the "autoEdit" property for details.
534

void QDataTable::setColumn ( uint col, const QString & fieldName, const

536       QString & label = QString::null, int width = -1, const QIconSet &
537       iconset = QIconSet ( ) ) [virtual]
538       Sets the col column to display using the field fieldName, column label
539       label, width width and iconset iconset.
540
541       If label is specified, it is used as the column's header label,
542       otherwise the field's display label is used when setSqlCursor() is
543       called. The iconset is used to set the icon used by the column header;
544       by default there is no icon.
545
546       See also setSqlCursor() and refresh().
547

void QDataTable::setColumnWidth ( int col, int w ) [virtual slot]

549       Sets the column col to the width w. Note that unlike QTable the
550       QDataTable is not immediately redrawn, you must call
551       refresh(QDataTable::RefreshColumns) yourself.
552
553       See also refresh().
554
555       Reimplemented from QTable.
556

void QDataTable::setConfirmCancels ( bool confirm ) [virtual]

558       Sets whether the data table confirms cancel operations to confirm. See
559       the "confirmCancels" property for details.
560

void QDataTable::setConfirmDelete ( bool confirm ) [virtual]

562       Sets whether the data table confirms delete operations to confirm. See
563       the "confirmDelete" property for details.
564

void QDataTable::setConfirmEdits ( bool confirm ) [virtual]

566       Sets whether the data table confirms edit operations to confirm. See
567       the "confirmEdits" property for details.
568

void QDataTable::setConfirmInsert ( bool confirm ) [virtual]

570       Sets whether the data table confirms insert operations to confirm. See
571       the "confirmInsert" property for details.
572

void QDataTable::setConfirmUpdate ( bool confirm ) [virtual]

574       Sets whether the data table confirms update operations to confirm. See
575       the "confirmUpdate" property for details.
576

void QDataTable::setDateFormat ( const DateFormat f ) [virtual]

578       Sets the format used for displaying date/time values to f. See the
579       "dateFormat" property for details.
580

void QDataTable::setFalseText ( const QString & falseText ) [virtual]

582       Sets the text used to represent false values to falseText. See the
583       "falseText" property for details.
584

void QDataTable::setFilter ( const QString & filter ) [virtual]

586       Sets the data filter for the data table to filter. See the "filter"
587       property for details.
588

void QDataTable::setNullText ( const QString & nullText ) [virtual]

590       Sets the text used to represent NULL values to nullText. See the
591       "nullText" property for details.
592

void QDataTable::setSize ( QSqlCursor * sql ) [protected]

594       If the cursor's sql driver supports query sizes, the number of rows in
595       the table is set to the size of the query. Otherwise, the table
596       dynamically resizes itself as it is scrolled. If sql is not active, it
597       is made active by issuing a select() on the cursor using the sql
598       cursor's current filter and current sort.
599

void QDataTable::setSort ( const QStringList & sort ) [virtual]

601       Sets the data table's sort to sort. See the "sort" property for
602       details.
603

void QDataTable::setSort ( const QSqlIndex & sort ) [virtual]

605       This is an overloaded member function, provided for convenience. It
606       behaves essentially like the above function.
607
608       Sets the sort to be applied to the displayed data to sort. If there is
609       no current cursor, nothing happens. A QSqlIndex contains field names
610       and their ordering (ASC or DESC); these are used to compose the ORDER
611       BY clause.
612
613       See also sort.
614

void QDataTable::setSqlCursor ( QSqlCursor * cursor = 0, bool autoPopulate =

616       FALSE, bool autoDelete = FALSE ) [virtual]
617       Sets cursor as the data source for the table. To force the display of
618       the data from cursor, use refresh(). If autoPopulate is TRUE, columns
619       are automatically created based upon the fields in the cursor record.
620       If autoDelete is TRUE (the default is FALSE), the table will take
621       ownership of the cursor and delete it when appropriate. If the cursor
622       is read-only, the table becomes read-only. The table adopts the
623       cursor's driver's definition for representing NULL values as strings.
624
625       See also refresh(), readOnly, setAutoDelete(), and
626       QSqlDriver::nullText().
627

void QDataTable::setTrueText ( const QString & trueText ) [virtual]

629       Sets the text used to represent true values to trueText. See the
630       "trueText" property for details.
631

QStringList QDataTable::sort () const

633       Returns the data table's sort. See the "sort" property for details.
634

void QDataTable::sortAscending ( int col ) [virtual slot]

636       Sorts column col in ascending order.
637
638       See also sorting.
639

void QDataTable::sortColumn ( int col, bool ascending = TRUE, bool wholeRows =

641       FALSE ) [virtual]
642       Sorts column col in ascending order if ascending is TRUE (the default);
643       otherwise sorts in descending order.
644
645       The wholeRows parameter is ignored; QDataTable always sorts whole rows
646       by the specified column.
647
648       Reimplemented from QTable.
649

void QDataTable::sortDescending ( int col ) [virtual slot]

651       Sorts column col in descending order.
652
653       See also sorting.
654

QSqlCursor * QDataTable::sqlCursor () const

656       Returns the cursor used by the data table.
657

QString QDataTable::text ( int row, int col ) const [virtual]

659       Returns the text in cell row, col, or an empty string if the cell is
660       empty. If the cell's value is NULL then nullText() will be returned. If
661       the cell does not exist then QString::null is returned.
662
663       Reimplemented from QTable.
664

QString QDataTable::trueText () const

666       Returns the text used to represent true values. See the "trueText"
667       property for details.
668

bool QDataTable::updateCurrent () [virtual protected]

670       For an editable table, issues an update using the cursor's edit buffer.
671       If there is no current cursor or there is no current selection, nothing
672       happens. If confirmEdits() or confirmUpdate() is TRUE, confirmEdit() is
673       called to confirm the update. Returns TRUE if the update succeeded;
674       otherwise returns FALSE.
675
676       The underlying cursor must have a valid primary index to ensure that a
677       unique record is updated within the database otherwise the database may
678       be changed to an inconsistent state.
679

QVariant QDataTable::value ( int row, int col ) const

681       Returns the value in cell row, col, or an invalid value if the cell
682       does not exist or has no value.
683
684   Property Documentation

bool autoEdit

686       This property holds whether the data table automatically applies edits.
687
688       The default value for this property is TRUE. When the user begins an
689       insert or update in the table there are two possible outcomes when they
690       navigate to another record:
691
692       <ol type=1>
693
694       the insert or update is is performed -- this occurs if autoEdit is TRUE
695
696       the insert or update is abandoned -- this occurs if autoEdit is FALSE
697
698       Set this property's value with setAutoEdit() and get this property's
699       value with autoEdit().
700

bool confirmCancels

702       This property holds whether the data table confirms cancel operations.
703
704       If the confirmCancel property is TRUE, all cancels must be confirmed by
705       the user through a message box (this behavior can be changed by
706       overriding the confirmCancel() function), otherwise all cancels occur
707       immediately. The default is FALSE.
708
709       See also confirmEdits and confirmCancel().
710
711       Set this property's value with setConfirmCancels() and get this
712       property's value with confirmCancels().
713

bool confirmDelete

715       This property holds whether the data table confirms delete operations.
716
717       If the confirmDelete property is TRUE, all deletions must be confirmed
718       by the user through a message box (this behaviour can be changed by
719       overriding the confirmEdit() function), otherwise all delete operations
720       occur immediately.
721
722       See also confirmCancels, confirmEdits, confirmUpdate, and
723       confirmInsert.
724
725       Set this property's value with setConfirmDelete() and get this
726       property's value with confirmDelete().
727

bool confirmEdits

729       This property holds whether the data table confirms edit operations.
730
731       If the confirmEdits property is TRUE, the data table confirms all edit
732       operations (inserts, updates and deletes). Finer control of edit
733       confirmation can be achieved using confirmCancels, confirmInsert,
734       confirmUpdate and confirmDelete.
735
736       See also confirmCancels, confirmInsert, confirmUpdate, and
737       confirmDelete.
738
739       Set this property's value with setConfirmEdits() and get this
740       property's value with confirmEdits().
741

bool confirmInsert

743       This property holds whether the data table confirms insert operations.
744
745       If the confirmInsert property is TRUE, all insertions must be confirmed
746       by the user through a message box (this behaviour can be changed by
747       overriding the confirmEdit() function), otherwise all insert operations
748       occur immediately.
749
750       See also confirmCancels, confirmEdits, confirmUpdate, and
751       confirmDelete.
752
753       Set this property's value with setConfirmInsert() and get this
754       property's value with confirmInsert().
755

bool confirmUpdate

757       This property holds whether the data table confirms update operations.
758
759       If the confirmUpdate property is TRUE, all updates must be confirmed by
760       the user through a message box (this behaviour can be changed by
761       overriding the confirmEdit() function), otherwise all update operations
762       occur immediately.
763
764       See also confirmCancels, confirmEdits, confirmInsert, and
765       confirmDelete.
766
767       Set this property's value with setConfirmUpdate() and get this
768       property's value with confirmUpdate().
769

DateFormat dateFormat

771       This property holds the format used for displaying date/time values.
772
773       The dateFormat property is used for displaying date/time values in the
774       table. The default value is Qt::LocalDate.
775
776       Set this property's value with setDateFormat() and get this property's
777       value with dateFormat().
778

QString falseText

780       This property holds the text used to represent false values.
781
782       The falseText property will be used to represent NULL values in the
783       table. The default value is "False".
784
785       Set this property's value with setFalseText() and get this property's
786       value with falseText().
787

QString filter

789       This property holds the data filter for the data table.
790
791       The filter applies to the data shown in the table. To view data with a
792       new filter, use refresh(). A filter string is an SQL WHERE clause
793       without the WHERE keyword.
794
795       There is no default filter.
796
797       See also sort.
798
799       Set this property's value with setFilter() and get this property's
800       value with filter().
801

QString nullText

803       This property holds the text used to represent NULL values.
804
805       The nullText property will be used to represent NULL values in the
806       table. The default value is provided by the cursor's driver.
807
808       Set this property's value with setNullText() and get this property's
809       value with nullText().
810

int numCols

812       This property holds the number of columns in the table.
813
814       Get this property's value with numCols().
815

int numRows

817       This property holds the number of rows in the table.
818
819       Get this property's value with numRows().
820

QStringList sort

822       This property holds the data table's sort.
823
824       The table's sort affects the order in which data records are displayed
825       in the table. To apply a sort, use refresh().
826
827       When examining the sort property, a string list is returned with each
828       item having the form 'fieldname order' (e.g., 'id ASC', 'surname
829       DESC').
830
831       There is no default sort.
832
833       Note that if you want to iterate over the sort list, you should iterate
834       over a copy, e.g.
835
836           QStringList list = myDataTable.sort();
837           QStringList::Iterator it = list.begin();
838           while( it != list.end() ) {
839               myProcessing( *it );
840               ++it;
841           }
842
843       See also filter and refresh().
844
845       Set this property's value with setSort() and get this property's value
846       with sort().
847

QString trueText

849       This property holds the text used to represent true values.
850
851       The trueText property will be used to represent NULL values in the
852       table. The default value is "True".
853
854       Set this property's value with setTrueText() and get this property's
855       value with trueText().
856
857

SEE ALSO

859       http://doc.trolltech.com/qdatatable.html
860       http://www.trolltech.com/faq/tech.html
861
863       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
864       license file included in the distribution for a complete license
865       statement.
866

AUTHOR

868       Generated automatically from the source code.
869

BUGS

871       If you find a bug in Qt, please report it as described in
872       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
873       help you. Thank you.
874
875       The definitive Qt documentation is provided in HTML format; it is
876       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
877       web browser. This man page is provided as a convenience for those users
878       who prefer man pages, although this format is not officially supported
879       by Trolltech.
880
881       If you find errors in this manual page, please report them to qt-
882       bugs@trolltech.com.  Please include the name of the manual page
883       (qdatatable.3qt) and the Qt version (3.3.8).
884
885
886
887Trolltech AS                    2 February 2007                QDataTable(3qt)
Impressum