You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
810 lines
55 KiB
810 lines
55 KiB
14 years ago
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||
|
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/sql/qdatatable.cpp:130 -->
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||
|
<title>QDataTable Class</title>
|
||
|
<style type="text/css"><!--
|
||
|
fn { margin-left: 1cm; text-indent: -1cm; }
|
||
|
a:link { color: #004faf; text-decoration: none }
|
||
|
a:visited { color: #672967; text-decoration: none }
|
||
|
body { background: #ffffff; color: black; }
|
||
|
--></style>
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||
|
<tr bgcolor="#E5E5E5">
|
||
|
<td valign=center>
|
||
|
<a href="index.html">
|
||
|
<font color="#004faf">Home</font></a>
|
||
|
| <a href="classes.html">
|
||
|
<font color="#004faf">All Classes</font></a>
|
||
|
| <a href="mainclasses.html">
|
||
|
<font color="#004faf">Main Classes</font></a>
|
||
|
| <a href="annotated.html">
|
||
|
<font color="#004faf">Annotated</font></a>
|
||
|
| <a href="groups.html">
|
||
|
<font color="#004faf">Grouped Classes</font></a>
|
||
|
| <a href="functions.html">
|
||
|
<font color="#004faf">Functions</font></a>
|
||
|
</td>
|
||
|
<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>
|
||
|
|
||
|
<p>The QDataTable class provides a flexible SQL table widget that supports browsing and editing.
|
||
|
<a href="#details">More...</a>
|
||
|
<p><tt>#include <<a href="qdatatable-h.html">qdatatable.h</a>></tt>
|
||
|
<p>Inherits <a href="qtable.html">QTable</a>.
|
||
|
<p><a href="qdatatable-members.html">List of all member functions.</a>
|
||
|
<h2>Public Members</h2>
|
||
|
<ul>
|
||
|
<li class=fn><a href="#QDataTable"><b>QDataTable</b></a> ( QWidget * parent = 0, const char * name = 0 )</li>
|
||
|
<li class=fn><a href="#QDataTable-2"><b>QDataTable</b></a> ( QSqlCursor * cursor, bool autoPopulate = FALSE, QWidget * parent = 0, const char * name = 0 )</li>
|
||
|
<li class=fn><a href="#~QDataTable"><b>~QDataTable</b></a> ()</li>
|
||
|
<li class=fn>virtual void <a href="#addColumn"><b>addColumn</b></a> ( const QString & fieldName, const QString & label = QString::null, int width = -1, const QIconSet & iconset = QIconSet ( ) )</li>
|
||
|
<li class=fn>virtual void <a href="#removeColumn"><b>removeColumn</b></a> ( uint col )</li>
|
||
|
<li class=fn>virtual void <a href="#setColumn"><b>setColumn</b></a> ( uint col, const QString & fieldName, const QString & label = QString::null, int width = -1, const QIconSet & iconset = QIconSet ( ) )</li>
|
||
|
<li class=fn>QString <a href="#nullText"><b>nullText</b></a> () const</li>
|
||
|
<li class=fn>QString <a href="#trueText"><b>trueText</b></a> () const</li>
|
||
|
<li class=fn>QString <a href="#falseText"><b>falseText</b></a> () const</li>
|
||
|
<li class=fn>DateFormat <a href="#dateFormat"><b>dateFormat</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#confirmEdits"><b>confirmEdits</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#confirmInsert"><b>confirmInsert</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#confirmUpdate"><b>confirmUpdate</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#confirmDelete"><b>confirmDelete</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#confirmCancels"><b>confirmCancels</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#autoDelete"><b>autoDelete</b></a> () const</li>
|
||
|
<li class=fn>bool <a href="#autoEdit"><b>autoEdit</b></a> () const</li>
|
||
|
<li class=fn>QString <a href="#filter"><b>filter</b></a> () const</li>
|
||
|
<li class=fn>QStringList <a href="#sort"><b>sort</b></a> () const</li>
|
||
|
<li class=fn>virtual void <a href="#setSqlCursor"><b>setSqlCursor</b></a> ( QSqlCursor * cursor = 0, bool autoPopulate = FALSE, bool autoDelete = FALSE )</li>
|
||
|
<li class=fn>QSqlCursor * <a href="#sqlCursor"><b>sqlCursor</b></a> () const</li>
|
||
|
<li class=fn>virtual void <a href="#setNullText"><b>setNullText</b></a> ( const QString & nullText )</li>
|
||
|
<li class=fn>virtual void <a href="#setTrueText"><b>setTrueText</b></a> ( const QString & trueText )</li>
|
||
|
<li class=fn>virtual void <a href="#setFalseText"><b>setFalseText</b></a> ( const QString & falseText )</li>
|
||
|
<li class=fn>virtual void <a href="#setDateFormat"><b>setDateFormat</b></a> ( const DateFormat f )</li>
|
||
|
<li class=fn>virtual void <a href="#setConfirmEdits"><b>setConfirmEdits</b></a> ( bool confirm )</li>
|
||
|
<li class=fn>virtual void <a href="#setConfirmInsert"><b>setConfirmInsert</b></a> ( bool confirm )</li>
|
||
|
<li class=fn>virtual void <a href="#setConfirmUpdate"><b>setConfirmUpdate</b></a> ( bool confirm )</li>
|
||
|
<li class=fn>virtual void <a href="#setConfirmDelete"><b>setConfirmDelete</b></a> ( bool confirm )</li>
|
||
|
<li class=fn>virtual void <a href="#setConfirmCancels"><b>setConfirmCancels</b></a> ( bool confirm )</li>
|
||
|
<li class=fn>virtual void <a href="#setAutoDelete"><b>setAutoDelete</b></a> ( bool enable )</li>
|
||
|
<li class=fn>virtual void <a href="#setAutoEdit"><b>setAutoEdit</b></a> ( bool autoEdit )</li>
|
||
|
<li class=fn>virtual void <a href="#setFilter"><b>setFilter</b></a> ( const QString & filter )</li>
|
||
|
<li class=fn>virtual void <a href="#setSort"><b>setSort</b></a> ( const QStringList & sort )</li>
|
||
|
<li class=fn>virtual void <a href="#setSort-2"><b>setSort</b></a> ( const QSqlIndex & sort )</li>
|
||
|
<li class=fn>enum <a href="#Refresh-enum"><b>Refresh</b></a> { RefreshData = 1, RefreshColumns = 2, RefreshAll = 3 }</li>
|
||
|
<li class=fn>void <a href="#refresh-2"><b>refresh</b></a> ( Refresh mode )</li>
|
||
|
<li class=fn>virtual void <a href="#sortColumn"><b>sortColumn</b></a> ( int col, bool ascending = TRUE, bool wholeRows = FALSE )</li>
|
||
|
<li class=fn>virtual QString <a href="#text"><b>text</b></a> ( int row, int col ) const</li>
|
||
|
<li class=fn>QVariant <a href="#value"><b>value</b></a> ( int row, int col ) const</li>
|
||
|
<li class=fn>QSqlRecord * <a href="#currentRecord"><b>currentRecord</b></a> () const</li>
|
||
|
<li class=fn>void <a href="#installEditorFactory"><b>installEditorFactory</b></a> ( QSqlEditorFactory * f )</li>
|
||
|
<li class=fn>void <a href="#installPropertyMap"><b>installPropertyMap</b></a> ( QSqlPropertyMap * m )</li>
|
||
|
<li class=fn>virtual int <a href="#numCols"><b>numCols</b></a> () const</li>
|
||
|
<li class=fn>virtual int <a href="#numRows"><b>numRows</b></a> () const</li>
|
||
|
</ul>
|
||
|
<h2>Public Slots</h2>
|
||
|
<ul>
|
||
|
<li class=fn>virtual void <a href="#find"><b>find</b></a> ( const QString & str, bool caseSensitive, bool backwards )</li>
|
||
|
<li class=fn>virtual void <a href="#sortAscending"><b>sortAscending</b></a> ( int col )</li>
|
||
|
<li class=fn>virtual void <a href="#sortDescending"><b>sortDescending</b></a> ( int col )</li>
|
||
|
<li class=fn>virtual void <a href="#refresh"><b>refresh</b></a> ()</li>
|
||
|
<li class=fn>virtual void <a href="#setColumnWidth"><b>setColumnWidth</b></a> ( int col, int w )</li>
|
||
|
<li class=fn>virtual void <a href="#adjustColumn"><b>adjustColumn</b></a> ( int col )</li>
|
||
|
</ul>
|
||
|
<h2>Signals</h2>
|
||
|
<ul>
|
||
|
<li class=fn>void <a href="#currentChanged"><b>currentChanged</b></a> ( QSqlRecord * record )</li>
|
||
|
<li class=fn>void <a href="#primeInsert"><b>primeInsert</b></a> ( QSqlRecord * buf )</li>
|
||
|
<li class=fn>void <a href="#primeUpdate"><b>primeUpdate</b></a> ( QSqlRecord * buf )</li>
|
||
|
<li class=fn>void <a href="#primeDelete"><b>primeDelete</b></a> ( QSqlRecord * buf )</li>
|
||
|
<li class=fn>void <a href="#beforeInsert"><b>beforeInsert</b></a> ( QSqlRecord * buf )</li>
|
||
|
<li class=fn>void <a href="#beforeUpdate"><b>beforeUpdate</b></a> ( QSqlRecord * buf )</li>
|
||
|
<li class=fn>void <a href="#beforeDelete"><b>beforeDelete</b></a> ( QSqlRecord * buf )</li>
|
||
|
<li class=fn>void <a href="#cursorChanged"><b>cursorChanged</b></a> ( QSql::Op mode )</li>
|
||
|
</ul>
|
||
|
<h2>Properties</h2>
|
||
|
<ul>
|
||
|
<li class=fn>bool <a href="#autoEdit-prop"><b>autoEdit</b></a> - whether the data table automatically applies edits</li>
|
||
|
<li class=fn>bool <a href="#confirmCancels-prop"><b>confirmCancels</b></a> - whether the data table confirms cancel operations</li>
|
||
|
<li class=fn>bool <a href="#confirmDelete-prop"><b>confirmDelete</b></a> - whether the data table confirms delete operations</li>
|
||
|
<li class=fn>bool <a href="#confirmEdits-prop"><b>confirmEdits</b></a> - whether the data table confirms edit operations</li>
|
||
|
<li class=fn>bool <a href="#confirmInsert-prop"><b>confirmInsert</b></a> - whether the data table confirms insert operations</li>
|
||
|
<li class=fn>bool <a href="#confirmUpdate-prop"><b>confirmUpdate</b></a> - whether the data table confirms update operations</li>
|
||
|
<li class=fn>DateFormat <a href="#dateFormat-prop"><b>dateFormat</b></a> - the format used for displaying date/time values</li>
|
||
|
<li class=fn>QString <a href="#falseText-prop"><b>falseText</b></a> - the text used to represent false values</li>
|
||
|
<li class=fn>QString <a href="#filter-prop"><b>filter</b></a> - the data filter for the data table</li>
|
||
|
<li class=fn>QString <a href="#nullText-prop"><b>nullText</b></a> - the text used to represent NULL values</li>
|
||
|
<li class=fn>int <a href="#numCols-prop"><b>numCols</b></a> - the number of columns in the table <em>(read only)</em></li>
|
||
|
<li class=fn>int <a href="#numRows-prop"><b>numRows</b></a> - the number of rows in the table <em>(read only)</em></li>
|
||
|
<li class=fn>QStringList <a href="#sort-prop"><b>sort</b></a> - the data table's sort</li>
|
||
|
<li class=fn>QString <a href="#trueText-prop"><b>trueText</b></a> - the text used to represent true values</li>
|
||
|
</ul>
|
||
|
<h2>Protected Members</h2>
|
||
|
<ul>
|
||
|
<li class=fn>virtual bool <a href="#insertCurrent"><b>insertCurrent</b></a> ()</li>
|
||
|
<li class=fn>virtual bool <a href="#updateCurrent"><b>updateCurrent</b></a> ()</li>
|
||
|
<li class=fn>virtual bool <a href="#deleteCurrent"><b>deleteCurrent</b></a> ()</li>
|
||
|
<li class=fn>virtual QSql::Confirm <a href="#confirmEdit"><b>confirmEdit</b></a> ( QSql::Op m )</li>
|
||
|
<li class=fn>virtual QSql::Confirm <a href="#confirmCancel"><b>confirmCancel</b></a> ( QSql::Op m )</li>
|
||
|
<li class=fn>virtual void <a href="#handleError"><b>handleError</b></a> ( const QSqlError & e )</li>
|
||
|
<li class=fn>virtual bool <a href="#beginInsert"><b>beginInsert</b></a> ()</li>
|
||
|
<li class=fn>virtual QWidget * <a href="#beginUpdate"><b>beginUpdate</b></a> ( int row, int col, bool replace )</li>
|
||
|
<li class=fn>int <a href="#indexOf"><b>indexOf</b></a> ( uint i ) const</li>
|
||
|
<li class=fn>void <a href="#reset"><b>reset</b></a> ()</li>
|
||
|
<li class=fn>void <a href="#setSize"><b>setSize</b></a> ( QSqlCursor * sql )</li>
|
||
|
<li class=fn>virtual void <a href="#paintField"><b>paintField</b></a> ( QPainter * p, const QSqlField * field, const QRect & cr, bool selected )</li>
|
||
|
<li class=fn>virtual int <a href="#fieldAlignment"><b>fieldAlignment</b></a> ( const QSqlField * field )</li>
|
||
|
</ul>
|
||
|
<hr><a name="details"></a><h2>Detailed Description</h2>
|
||
|
|
||
|
|
||
|
The QDataTable class provides a flexible SQL table widget that supports browsing and editing.
|
||
|
<p>
|
||
|
|
||
|
|
||
|
<p> QDataTable supports various functions for presenting and editing
|
||
|
SQL data from a <a href="qsqlcursor.html">QSqlCursor</a> in a table.
|
||
|
<p> If you want a to present your data in a form use <a href="qdatabrowser.html">QDataBrowser</a>, or
|
||
|
for read-only forms, <a href="qdataview.html">QDataView</a>.
|
||
|
<p> When displaying data, QDataTable only retrieves data for visible
|
||
|
rows. If the driver supports the 'query size' property the
|
||
|
QDataTable will have the correct number of rows and the vertical
|
||
|
scrollbar will accurately reflect the number of rows displayed in
|
||
|
proportion to the number of rows in the dataset. If the driver
|
||
|
does not support the 'query size' property, rows are dynamically
|
||
|
fetched from the database on an as-needed basis with the scrollbar
|
||
|
becoming more accurate as the user scrolls down through the
|
||
|
records. This allows extremely large queries to be displayed as
|
||
|
quickly as possible, with minimum memory usage.
|
||
|
<p> QDataTable inherits <a href="qtable.html">QTable</a>'s API and extends it with functions to
|
||
|
sort and filter the data and sort columns. See <a href="#setSqlCursor">setSqlCursor</a>(),
|
||
|
<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>().
|
||
|
<p> When displaying editable cursors, cell editing will be enabled.
|
||
|
(For more information on editable cursors, see <a href="qsqlcursor.html">QSqlCursor</a>).
|
||
|
QDataTable can be used to modify existing data and to add new
|
||
|
records. When a user makes changes to a field in the table, the
|
||
|
cursor's edit buffer is used. The table will not send changes in
|
||
|
the edit buffer to the database until the user moves to a
|
||
|
different record in the grid or presses Enter. Cell editing is
|
||
|
initiated by pressing F2 (or right clicking and then clicking the
|
||
|
appropriate popup menu item) and canceled by pressing Esc. If
|
||
|
there is a problem updating or adding data, errors are handled
|
||
|
automatically (see <a href="#handleError">handleError</a>() to change this behavior). Note
|
||
|
that if <a href="#autoEdit">autoEdit</a>() is FALSE navigating to another record will
|
||
|
cancel the insert or update.
|
||
|
<p> The user can be asked to confirm all edits with <a href="#setConfirmEdits">setConfirmEdits</a>().
|
||
|
For more precise control use <a href="#setConfirmInsert">setConfirmInsert</a>(),
|
||
|
<a href="#setConfirmUpdate">setConfirmUpdate</a>(), <a href="#setConfirmDelete">setConfirmDelete</a>() and <a href="#setConfirmCancels">setConfirmCancels</a>().
|
||
|
Use <a href="#setAutoEdit">setAutoEdit</a>() to control the behaviour of the table when the
|
||
|
user edits a record and then navigates. (Note that <a href="#setAutoDelete">setAutoDelete</a>()
|
||
|
is unrelated; it is used to set whether the <a href="qsqlcursor.html">QSqlCursor</a> is deleted
|
||
|
when the table is deleted.)
|
||
|
<p> Since the data table can perform edits, it must be able to
|
||
|
uniquely identify every record so that edits are correctly
|
||
|
applied. Because of this the underlying cursor must have a valid
|
||
|
primary index to ensure that a unique record is inserted, updated
|
||
|
or deleted within the database otherwise the database may be
|
||
|
changed to an inconsistent state.
|
||
|
<p> QDataTable creates editors using the default <a href="qsqleditorfactory.html">QSqlEditorFactory</a>.
|
||
|
Different editor factories can be used by calling
|
||
|
<a href="#installEditorFactory">installEditorFactory</a>(). A property map is used to map between the
|
||
|
cell's value and the editor. You can use your own property map
|
||
|
with <a href="#installPropertyMap">installPropertyMap</a>().
|
||
|
<p> The contents of a cell is available as a <a href="qstring.html">QString</a> with <a href="#text">text</a>() or as
|
||
|
a <a href="qvariant.html">QVariant</a> with <a href="#value">value</a>(). The current record is returned by
|
||
|
<a href="#currentRecord">currentRecord</a>(). Use the <a href="#find">find</a>() function to search for a string in
|
||
|
the table.
|
||
|
<p> Editing actions can be applied programatically. For example, the
|
||
|
<a href="#insertCurrent">insertCurrent</a>() function reads the fields from the current record
|
||
|
into the cursor and performs the insert. The <a href="#updateCurrent">updateCurrent</a>() and
|
||
|
<a href="#deleteCurrent">deleteCurrent</a>() functions perform similarly to update and delete
|
||
|
the current record respectively.
|
||
|
<p> Columns in the table can be created automatically based on the
|
||
|
cursor (see <a href="#setSqlCursor">setSqlCursor</a>()). Columns can be manipulated manually
|
||
|
using <a href="#addColumn">addColumn</a>(), <a href="#removeColumn">removeColumn</a>() and <a href="#setColumn">setColumn</a>().
|
||
|
<p> The table automatically copies many of the properties of the
|
||
|
cursor to format the display of data within cells (alignment,
|
||
|
visibility, etc.). The cursor can be changed with setSqlCursor().
|
||
|
The filter (see <a href="#setFilter">setFilter</a>()) and sort defined within the table are
|
||
|
used instead of the filter and sort set on the cursor. For sorting
|
||
|
options see <a href="#setSort">setSort</a>(), <a href="#sortColumn">sortColumn</a>(), <a href="#sortAscending">sortAscending</a>() and
|
||
|
<a href="#sortDescending">sortDescending</a>(). Note that sorting operations will not behave as
|
||
|
expected if you are using a <a href="qsqlselectcursor.html">QSqlSelectCursor</a> because it uses
|
||
|
user-defined SQL queries to obtain data.
|
||
|
<p> The text used to represent NULL, TRUE and FALSE values can be
|
||
|
changed with <a href="#setNullText">setNullText</a>(), <a href="#setTrueText">setTrueText</a>() and <a href="#setFalseText">setFalseText</a>()
|
||
|
respectively. You can change the appearance of cells by
|
||
|
reimplementing <a href="#paintField">paintField</a>().
|
||
|
<p> Whenever a new row is selected in the table the <a href="#currentChanged">currentChanged</a>()
|
||
|
signal is emitted. The <a href="#primeInsert">primeInsert</a>() signal is emitted when an
|
||
|
insert is initiated. The <a href="#primeUpdate">primeUpdate</a>() and <a href="#primeDelete">primeDelete</a>() signals
|
||
|
are emitted when update and deletion are initiated respectively.
|
||
|
Just before the database is updated a signal is emitted;
|
||
|
<a href="#beforeInsert">beforeInsert</a>(), <a href="#beforeUpdate">beforeUpdate</a>() or <a href="#beforeDelete">beforeDelete</a>() as appropriate.
|
||
|
<p> <p>See also <a href="database.html">Database Classes</a>.
|
||
|
|
||
|
<hr><h2>Member Type Documentation</h2>
|
||
|
<h3 class=fn><a name="Refresh-enum"></a>QDataTable::Refresh</h3>
|
||
|
|
||
|
<p> This enum describes the refresh options.
|
||
|
<ul>
|
||
|
<li><tt>QDataTable::RefreshData</tt> - refresh the data, i.e. read it from the database
|
||
|
<li><tt>QDataTable::RefreshColumns</tt> - refresh the list of fields, e.g. the column headings
|
||
|
<li><tt>QDataTable::RefreshAll</tt> - refresh both the data and the list of fields
|
||
|
</ul>
|
||
|
<hr><h2>Member Function Documentation</h2>
|
||
|
<h3 class=fn><a name="QDataTable"></a>QDataTable::QDataTable ( <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 )
|
||
|
</h3>
|
||
|
Constructs a data table which is a child of <em>parent</em>, called
|
||
|
name <em>name</em>.
|
||
|
|
||
|
<h3 class=fn><a name="QDataTable-2"></a>QDataTable::QDataTable ( <a href="qsqlcursor.html">QSqlCursor</a> * cursor, bool autoPopulate = FALSE, <a href="qwidget.html">QWidget</a> * parent = 0, const char * name = 0 )
|
||
|
</h3>
|
||
|
Constructs a data table which is a child of <em>parent</em>, called name
|
||
|
<em>name</em> using the cursor <em>cursor</em>.
|
||
|
<p> If <em>autoPopulate</em> is TRUE (the default is FALSE), columns are
|
||
|
automatically created based upon the fields in the <em>cursor</em>
|
||
|
record. Note that <em>autoPopulate</em> only governs the creation of
|
||
|
columns; to load the cursor's data into the table use <a href="#refresh">refresh</a>().
|
||
|
<p> If the <em>cursor</em> is read-only, the table also becomes read-only.
|
||
|
In addition, the table adopts the cursor's driver's definition for
|
||
|
representing NULL values as strings.
|
||
|
|
||
|
<h3 class=fn><a name="~QDataTable"></a>QDataTable::~QDataTable ()
|
||
|
</h3>
|
||
|
Destroys the object and frees any allocated resources.
|
||
|
|
||
|
<h3 class=fn>void <a name="addColumn"></a>QDataTable::addColumn ( const <a href="qstring.html">QString</a> & fieldName, const <a href="qstring.html">QString</a> & label = QString::null, int width = -1, const <a href="qiconset.html">QIconSet</a> & iconset = QIconSet ( ) )<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Adds the next column to be displayed using the field <em>fieldName</em>,
|
||
|
column label <em>label</em>, width <em>width</em> and iconset <em>iconset</em>.
|
||
|
<p> If <em>label</em> is specified, it is used as the column's header label,
|
||
|
otherwise the field's display label is used when <a href="#setSqlCursor">setSqlCursor</a>() is
|
||
|
called. The <em>iconset</em> is used to set the icon used by the column
|
||
|
header; by default there is no icon.
|
||
|
<p> <p>See also <a href="#setSqlCursor">setSqlCursor</a>() and <a href="#refresh">refresh</a>().
|
||
|
|
||
|
<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>.
|
||
|
<h3 class=fn>void <a name="adjustColumn"></a>QDataTable::adjustColumn ( int col )<tt> [virtual slot]</tt>
|
||
|
</h3>
|
||
|
Resizes column <em>col</em> so that the column width is wide enough to
|
||
|
display the widest item the column contains (including the column
|
||
|
label). If the table's <a href="qsqlcursor.html">QSqlCursor</a> is not currently active, the
|
||
|
cursor will be refreshed before the column width is calculated. Be
|
||
|
aware that this function may be slow on tables that contain large
|
||
|
result sets.
|
||
|
|
||
|
<p>Reimplemented from <a href="qtable.html#adjustColumn">QTable</a>.
|
||
|
<h3 class=fn>bool <a name="autoDelete"></a>QDataTable::autoDelete () const
|
||
|
</h3>
|
||
|
Returns TRUE if the table will automatically delete the cursor
|
||
|
specified by <a href="#setSqlCursor">setSqlCursor</a>(); otherwise returns FALSE.
|
||
|
|
||
|
<h3 class=fn>bool <a name="autoEdit"></a>QDataTable::autoEdit () const
|
||
|
</h3><p>Returns TRUE if the data table automatically applies edits; otherwise returns FALSE.
|
||
|
See the <a href="qdatatable.html#autoEdit-prop">"autoEdit"</a> property for details.
|
||
|
<h3 class=fn>void <a name="beforeDelete"></a>QDataTable::beforeDelete ( <a href="qsqlrecord.html">QSqlRecord</a> * buf )<tt> [signal]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> This signal is emitted just before the currently selected record
|
||
|
is deleted from the database. The <em>buf</em> parameter points to the
|
||
|
edit buffer being deleted. Connect to this signal to, for example,
|
||
|
copy some of the fields for later use.
|
||
|
|
||
|
<h3 class=fn>void <a name="beforeInsert"></a>QDataTable::beforeInsert ( <a href="qsqlrecord.html">QSqlRecord</a> * buf )<tt> [signal]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> This signal is emitted just before the cursor's edit buffer is
|
||
|
inserted into the database. The <em>buf</em> parameter points to the
|
||
|
edit buffer being inserted. Connect to this signal to, for
|
||
|
example, populate a key field with a unique sequence number.
|
||
|
|
||
|
<h3 class=fn>void <a name="beforeUpdate"></a>QDataTable::beforeUpdate ( <a href="qsqlrecord.html">QSqlRecord</a> * buf )<tt> [signal]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> This signal is emitted just before the cursor's edit buffer is
|
||
|
updated in the database. The <em>buf</em> parameter points to the edit
|
||
|
buffer being updated. Connect to this signal when you want to
|
||
|
transform the user's data behind-the-scenes.
|
||
|
|
||
|
<h3 class=fn>bool <a name="beginInsert"></a>QDataTable::beginInsert ()<tt> [virtual protected]</tt>
|
||
|
</h3>
|
||
|
Protected virtual function called when editing is about to begin
|
||
|
on a new record. If the table is read-only, or if there's no
|
||
|
cursor or the cursor does not allow inserts, nothing happens.
|
||
|
<p> Editing takes place using the cursor's edit buffer(see
|
||
|
<a href="qsqlcursor.html#editBuffer">QSqlCursor::editBuffer</a>()).
|
||
|
<p> When editing begins, a new row is created in the table marked with
|
||
|
an asterisk '*' in the row's vertical header column, i.e. at the
|
||
|
left of the row.
|
||
|
|
||
|
<h3 class=fn><a href="qwidget.html">QWidget</a> * <a name="beginUpdate"></a>QDataTable::beginUpdate ( int row, int col, bool replace )<tt> [virtual protected]</tt>
|
||
|
</h3>
|
||
|
Protected virtual function called when editing is about to begin
|
||
|
on an existing row. If the table is read-only, or if there's no
|
||
|
cursor, nothing happens.
|
||
|
<p> Editing takes place using the cursor's edit buffer (see
|
||
|
<a href="qsqlcursor.html#editBuffer">QSqlCursor::editBuffer</a>()).
|
||
|
<p> <em>row</em> and <em>col</em> refer to the row and column in the QDataTable.
|
||
|
<p> (<em>replace</em> is provided for reimplementors and reflects the API of
|
||
|
<a href="qtable.html#beginEdit">QTable::beginEdit</a>().)
|
||
|
|
||
|
<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> m )<tt> [virtual protected]</tt>
|
||
|
</h3>
|
||
|
Protected virtual function which returns a confirmation for
|
||
|
cancelling an edit mode of <em>m</em>. Derived classes can reimplement
|
||
|
this function to provide their own cancel dialog. The default
|
||
|
implementation uses a message box which prompts the user to
|
||
|
confirm the cancel.
|
||
|
|
||
|
<h3 class=fn>bool <a name="confirmCancels"></a>QDataTable::confirmCancels () const
|
||
|
</h3><p>Returns TRUE if the data table confirms cancel operations; otherwise returns FALSE.
|
||
|
See the <a href="qdatatable.html#confirmCancels-prop">"confirmCancels"</a> property for details.
|
||
|
<h3 class=fn>bool <a name="confirmDelete"></a>QDataTable::confirmDelete () const
|
||
|
</h3><p>Returns TRUE if the data table confirms delete operations; otherwise returns FALSE.
|
||
|
See the <a href="qdatatable.html#confirmDelete-prop">"confirmDelete"</a> property for details.
|
||
|
<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> m )<tt> [virtual protected]</tt>
|
||
|
</h3>
|
||
|
Protected virtual function which returns a confirmation for an
|
||
|
edit of mode <em>m</em>. Derived classes can reimplement this function
|
||
|
to provide their own confirmation dialog. The default
|
||
|
implementation uses a message box which prompts the user to
|
||
|
confirm the edit action.
|
||
|
|
||
|
<h3 class=fn>bool <a name="confirmEdits"></a>QDataTable::confirmEdits () const
|
||
|
</h3><p>Returns TRUE if the data table confirms edit operations; otherwise returns FALSE.
|
||
|
See the <a href="qdatatable.html#confirmEdits-prop">"confirmEdits"</a> property for details.
|
||
|
<h3 class=fn>bool <a name="confirmInsert"></a>QDataTable::confirmInsert () const
|
||
|
</h3><p>Returns TRUE if the data table confirms insert operations; otherwise returns FALSE.
|
||
|
See the <a href="qdatatable.html#confirmInsert-prop">"confirmInsert"</a> property for details.
|
||
|
<h3 class=fn>bool <a name="confirmUpdate"></a>QDataTable::confirmUpdate () const
|
||
|
</h3><p>Returns TRUE if the data table confirms update operations; otherwise returns FALSE.
|
||
|
See the <a href="qdatatable.html#confirmUpdate-prop">"confirmUpdate"</a> property for details.
|
||
|
<h3 class=fn>void <a name="currentChanged"></a>QDataTable::currentChanged ( <a href="qsqlrecord.html">QSqlRecord</a> * record )<tt> [signal]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> This signal is emitted whenever a new row is selected in the
|
||
|
table. The <em>record</em> parameter points to the contents of the newly
|
||
|
selected record.
|
||
|
|
||
|
<h3 class=fn><a href="qsqlrecord.html">QSqlRecord</a> * <a name="currentRecord"></a>QDataTable::currentRecord () const
|
||
|
</h3>
|
||
|
Returns the currently selected record, or 0 if there is no current
|
||
|
selection. The table owns the pointer, so do <em>not</em> delete it or
|
||
|
otherwise modify it or the cursor it points to.
|
||
|
|
||
|
<h3 class=fn>void <a name="cursorChanged"></a>QDataTable::cursorChanged ( <a href="qsql.html#Op-enum">QSql::Op</a> mode )<tt> [signal]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> This signal is emitted whenever the cursor record was changed due
|
||
|
to an edit. The <em>mode</em> parameter is the type of edit that just
|
||
|
took place.
|
||
|
|
||
|
<h3 class=fn><a href="qt.html#DateFormat-enum">DateFormat</a> <a name="dateFormat"></a>QDataTable::dateFormat () const
|
||
|
</h3><p>Returns the format used for displaying date/time values.
|
||
|
See the <a href="qdatatable.html#dateFormat-prop">"dateFormat"</a> property for details.
|
||
|
<h3 class=fn>bool <a name="deleteCurrent"></a>QDataTable::deleteCurrent ()<tt> [virtual protected]</tt>
|
||
|
</h3>
|
||
|
For an editable table, issues a delete on the current cursor's
|
||
|
primary index using the values of the currently selected row. If
|
||
|
there is no current cursor or there is no current selection,
|
||
|
nothing happens. If <a href="#confirmEdits">confirmEdits</a>() or <a href="#confirmDelete">confirmDelete</a>() is TRUE,
|
||
|
<a href="#confirmEdit">confirmEdit</a>() is called to confirm the delete. Returns TRUE if the
|
||
|
delete succeeded; otherwise FALSE.
|
||
|
<p> The underlying cursor must have a valid primary index to ensure
|
||
|
that a unique record is deleted within the database otherwise the
|
||
|
database may be changed to an inconsistent state.
|
||
|
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="falseText"></a>QDataTable::falseText () const
|
||
|
</h3><p>Returns the text used to represent false values.
|
||
|
See the <a href="qdatatable.html#falseText-prop">"falseText"</a> property for details.
|
||
|
<h3 class=fn>int <a name="fieldAlignment"></a>QDataTable::fieldAlignment ( const <a href="qsqlfield.html">QSqlField</a> * field )<tt> [virtual protected]</tt>
|
||
|
</h3>
|
||
|
Returns the alignment for <em>field</em>.
|
||
|
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="filter"></a>QDataTable::filter () const
|
||
|
</h3><p>Returns the data filter for the data table.
|
||
|
See the <a href="qdatatable.html#filter-prop">"filter"</a> property for details.
|
||
|
<h3 class=fn>void <a name="find"></a>QDataTable::find ( const <a href="qstring.html">QString</a> & str, bool caseSensitive, bool backwards )<tt> [virtual slot]</tt>
|
||
|
</h3>
|
||
|
Searches the current cursor for a cell containing the string <em>str</em> starting at the current cell and working forwards (or
|
||
|
backwards if <em>backwards</em> is TRUE). If the string is found, the
|
||
|
cell containing the string is set as the current cell. If <em>caseSensitive</em> is FALSE the case of <em>str</em> will be ignored.
|
||
|
<p> The search will wrap, i.e. if the first (or if backwards is TRUE,
|
||
|
last) cell is reached without finding <em>str</em> the search will
|
||
|
continue until it reaches the starting cell. If <em>str</em> is not
|
||
|
found the search will fail and the current cell will remain
|
||
|
unchanged.
|
||
|
|
||
|
<h3 class=fn>void <a name="handleError"></a>QDataTable::handleError ( const <a href="qsqlerror.html">QSqlError</a> & e )<tt> [virtual protected]</tt>
|
||
|
</h3>
|
||
|
Protected virtual function which is called when an error <em>e</em> has
|
||
|
occurred on the current <a href="qwidget.html#cursor">cursor</a>(). The default implementation
|
||
|
displays a warning message to the user with information about the
|
||
|
error.
|
||
|
|
||
|
<h3 class=fn>int <a name="indexOf"></a>QDataTable::indexOf ( uint i ) const<tt> [protected]</tt>
|
||
|
</h3>
|
||
|
Returns the index of the field within the current SQL query that
|
||
|
is displayed in column <em>i</em>.
|
||
|
|
||
|
<h3 class=fn>bool <a name="insertCurrent"></a>QDataTable::insertCurrent ()<tt> [virtual protected]</tt>
|
||
|
</h3>
|
||
|
For an editable table, issues an insert on the current cursor
|
||
|
using the values in the cursor's edit buffer. If there is no
|
||
|
current cursor or there is no current "insert" row, nothing
|
||
|
happens. If <a href="#confirmEdits">confirmEdits</a>() or <a href="#confirmInsert">confirmInsert</a>() is TRUE,
|
||
|
<a href="#confirmEdit">confirmEdit</a>() is called to confirm the insert. Returns TRUE if the
|
||
|
insert succeeded; otherwise returns FALSE.
|
||
|
<p> The underlying cursor must have a valid primary index to ensure
|
||
|
that a unique record is inserted within the database otherwise the
|
||
|
database may be changed to an inconsistent state.
|
||
|
|
||
|
<h3 class=fn>void <a name="installEditorFactory"></a>QDataTable::installEditorFactory ( <a href="qsqleditorfactory.html">QSqlEditorFactory</a> * f )
|
||
|
</h3>
|
||
|
Installs a new SQL editor factory <em>f</em>. This enables the user to
|
||
|
create and instantiate their own editors for use in cell editing.
|
||
|
Note that QDataTable takes ownership of this pointer, and will
|
||
|
delete it when it is no longer needed or when
|
||
|
<a href="#installEditorFactory">installEditorFactory</a>() is called again.
|
||
|
<p> <p>See also <a href="qsqleditorfactory.html">QSqlEditorFactory</a>.
|
||
|
|
||
|
<h3 class=fn>void <a name="installPropertyMap"></a>QDataTable::installPropertyMap ( <a href="qsqlpropertymap.html">QSqlPropertyMap</a> * m )
|
||
|
</h3>
|
||
|
Installs a new property map <em>m</em>. This enables the user to create
|
||
|
and instantiate their own property maps for use in cell editing.
|
||
|
Note that QDataTable takes ownership of this pointer, and will
|
||
|
delete it when it is no longer needed or when installPropertMap()
|
||
|
is called again.
|
||
|
<p> <p>See also <a href="qsqlpropertymap.html">QSqlPropertyMap</a>.
|
||
|
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="nullText"></a>QDataTable::nullText () const
|
||
|
</h3><p>Returns the text used to represent NULL values.
|
||
|
See the <a href="qdatatable.html#nullText-prop">"nullText"</a> property for details.
|
||
|
<h3 class=fn>int <a name="numCols"></a>QDataTable::numCols () const<tt> [virtual]</tt>
|
||
|
</h3><p>Returns the number of columns in the table.
|
||
|
See the <a href="qdatatable.html#numCols-prop">"numCols"</a> property for details.
|
||
|
<p>Reimplemented from <a href="qtable.html#numCols">QTable</a>.
|
||
|
<h3 class=fn>int <a name="numRows"></a>QDataTable::numRows () const<tt> [virtual]</tt>
|
||
|
</h3><p>Returns the number of rows in the table.
|
||
|
See the <a href="qdatatable.html#numRows-prop">"numRows"</a> property for details.
|
||
|
<p>Reimplemented from <a href="qtable.html#numRows">QTable</a>.
|
||
|
<h3 class=fn>void <a name="paintField"></a>QDataTable::paintField ( <a href="qpainter.html">QPainter</a> * p, const <a href="qsqlfield.html">QSqlField</a> * field, const <a href="qrect.html">QRect</a> & cr, bool selected )<tt> [virtual protected]</tt>
|
||
|
</h3>
|
||
|
Paints the <em>field</em> on the painter <em>p</em>. The painter has already
|
||
|
been translated to the appropriate cell's origin where the <em>field</em> is to be rendered. <em>cr</em> describes the cell coordinates in
|
||
|
the content coordinate system. The <em>selected</em> parameter is
|
||
|
ignored.
|
||
|
<p> If you want to draw custom field content you must reimplement
|
||
|
<a href="#paintField">paintField</a>() to do the custom drawing. The default implementation
|
||
|
renders the <em>field</em> value as text. If the field is NULL,
|
||
|
<a href="#nullText">nullText</a>() is displayed in the cell. If the field is Boolean,
|
||
|
<a href="#trueText">trueText</a>() or <a href="#falseText">falseText</a>() is displayed as appropriate.
|
||
|
|
||
|
<p>Example: <a href="sql.html#x2245">sql/overview/table4/main.cpp</a>.
|
||
|
<h3 class=fn>void <a name="primeDelete"></a>QDataTable::primeDelete ( <a href="qsqlrecord.html">QSqlRecord</a> * buf )<tt> [signal]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> This signal is emitted after the cursor is primed for delete by
|
||
|
the table, when a delete action is beginning on the table. The <em>buf</em> parameter points to the edit buffer being deleted. Connect to
|
||
|
this signal in order to, for example, record auditing information
|
||
|
on deletions.
|
||
|
|
||
|
<h3 class=fn>void <a name="primeInsert"></a>QDataTable::primeInsert ( <a href="qsqlrecord.html">QSqlRecord</a> * buf )<tt> [signal]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> This signal is emitted after the cursor is primed for insert by
|
||
|
the table, when an insert action is beginning on the table. The <em>buf</em> parameter points to the edit buffer being inserted. Connect to
|
||
|
this signal in order to, for example, <a href="primes.html#prime">prime</a> the record buffer with
|
||
|
default data values.
|
||
|
|
||
|
<h3 class=fn>void <a name="primeUpdate"></a>QDataTable::primeUpdate ( <a href="qsqlrecord.html">QSqlRecord</a> * buf )<tt> [signal]</tt>
|
||
|
</h3>
|
||
|
|
||
|
<p> This signal is emitted after the cursor is primed for update by
|
||
|
the table, when an update action is beginning on the table. The <em>buf</em> parameter points to the edit buffer being updated. Connect to
|
||
|
this signal in order to, for example, provide some visual feedback
|
||
|
that the user is in 'edit mode'.
|
||
|
|
||
|
<h3 class=fn>void <a name="refresh"></a>QDataTable::refresh ()<tt> [virtual slot]</tt>
|
||
|
</h3>
|
||
|
Refreshes the table. The cursor is refreshed using the current
|
||
|
filter, the current sort, and the currently defined columns.
|
||
|
Equivalent to calling <a href="#refresh">refresh</a>( QDataTable::RefreshData ).
|
||
|
|
||
|
<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>.
|
||
|
<h3 class=fn>void <a name="refresh-2"></a>QDataTable::refresh ( <a href="qdatatable.html#Refresh-enum">Refresh</a> mode )
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> Refreshes the table. If there is no currently defined cursor (see
|
||
|
<a href="#setSqlCursor">setSqlCursor</a>()), nothing happens. The <em>mode</em> parameter determines
|
||
|
which type of refresh will take place.
|
||
|
<p> <p>See also <a href="#Refresh-enum">Refresh</a>, <a href="#setSqlCursor">setSqlCursor</a>(), and <a href="#addColumn">addColumn</a>().
|
||
|
|
||
|
<h3 class=fn>void <a name="removeColumn"></a>QDataTable::removeColumn ( uint col )<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Removes column <em>col</em> from the list of columns to be displayed. If
|
||
|
<em>col</em> does not exist, nothing happens.
|
||
|
<p> <p>See also <a href="qsqlfield.html">QSqlField</a>.
|
||
|
|
||
|
<h3 class=fn>void <a name="reset"></a>QDataTable::reset ()<tt> [protected]</tt>
|
||
|
</h3>
|
||
|
Resets the table so that it displays no data.
|
||
|
<p> <p>See also <a href="#setSqlCursor">setSqlCursor</a>().
|
||
|
|
||
|
<h3 class=fn>void <a name="setAutoDelete"></a>QDataTable::setAutoDelete ( bool enable )<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Sets the cursor auto-delete flag to <em>enable</em>. If <em>enable</em> is
|
||
|
TRUE, the table will automatically delete the cursor specified by
|
||
|
<a href="#setSqlCursor">setSqlCursor</a>(). If <em>enable</em> is FALSE (the default), the cursor
|
||
|
will not be deleted.
|
||
|
|
||
|
<h3 class=fn>void <a name="setAutoEdit"></a>QDataTable::setAutoEdit ( bool autoEdit )<tt> [virtual]</tt>
|
||
|
</h3><p>Sets whether the data table automatically applies edits to <em>autoEdit</em>.
|
||
|
See the <a href="qdatatable.html#autoEdit-prop">"autoEdit"</a> property for details.
|
||
|
<h3 class=fn>void <a name="setColumn"></a>QDataTable::setColumn ( uint col, const <a href="qstring.html">QString</a> & fieldName, const <a href="qstring.html">QString</a> & label = QString::null, int width = -1, const <a href="qiconset.html">QIconSet</a> & iconset = QIconSet ( ) )<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Sets the <em>col</em> column to display using the field <em>fieldName</em>,
|
||
|
column label <em>label</em>, width <em>width</em> and iconset <em>iconset</em>.
|
||
|
<p> If <em>label</em> is specified, it is used as the column's header label,
|
||
|
otherwise the field's display label is used when <a href="#setSqlCursor">setSqlCursor</a>() is
|
||
|
called. The <em>iconset</em> is used to set the icon used by the column
|
||
|
header; by default there is no icon.
|
||
|
<p> <p>See also <a href="#setSqlCursor">setSqlCursor</a>() and <a href="#refresh">refresh</a>().
|
||
|
|
||
|
<h3 class=fn>void <a name="setColumnWidth"></a>QDataTable::setColumnWidth ( int col, int w )<tt> [virtual slot]</tt>
|
||
|
</h3>
|
||
|
Sets the column <em>col</em> to the width <em>w</em>. Note that unlike <a href="qtable.html">QTable</a>
|
||
|
the QDataTable is not immediately redrawn, you must call
|
||
|
<a href="#refresh">refresh</a>(QDataTable::RefreshColumns)
|
||
|
yourself.
|
||
|
<p> <p>See also <a href="#refresh">refresh</a>().
|
||
|
|
||
|
<p>Reimplemented from <a href="qtable.html#setColumnWidth">QTable</a>.
|
||
|
<h3 class=fn>void <a name="setConfirmCancels"></a>QDataTable::setConfirmCancels ( bool confirm )<tt> [virtual]</tt>
|
||
|
</h3><p>Sets whether the data table confirms cancel operations to <em>confirm</em>.
|
||
|
See the <a href="qdatatable.html#confirmCancels-prop">"confirmCancels"</a> property for details.
|
||
|
<h3 class=fn>void <a name="setConfirmDelete"></a>QDataTable::setConfirmDelete ( bool confirm )<tt> [virtual]</tt>
|
||
|
</h3><p>Sets whether the data table confirms delete operations to <em>confirm</em>.
|
||
|
See the <a href="qdatatable.html#confirmDelete-prop">"confirmDelete"</a> property for details.
|
||
|
<h3 class=fn>void <a name="setConfirmEdits"></a>QDataTable::setConfirmEdits ( bool confirm )<tt> [virtual]</tt>
|
||
|
</h3><p>Sets whether the data table confirms edit operations to <em>confirm</em>.
|
||
|
See the <a href="qdatatable.html#confirmEdits-prop">"confirmEdits"</a> property for details.
|
||
|
<h3 class=fn>void <a name="setConfirmInsert"></a>QDataTable::setConfirmInsert ( bool confirm )<tt> [virtual]</tt>
|
||
|
</h3><p>Sets whether the data table confirms insert operations to <em>confirm</em>.
|
||
|
See the <a href="qdatatable.html#confirmInsert-prop">"confirmInsert"</a> property for details.
|
||
|
<h3 class=fn>void <a name="setConfirmUpdate"></a>QDataTable::setConfirmUpdate ( bool confirm )<tt> [virtual]</tt>
|
||
|
</h3><p>Sets whether the data table confirms update operations to <em>confirm</em>.
|
||
|
See the <a href="qdatatable.html#confirmUpdate-prop">"confirmUpdate"</a> property for details.
|
||
|
<h3 class=fn>void <a name="setDateFormat"></a>QDataTable::setDateFormat ( const <a href="qt.html#DateFormat-enum">DateFormat</a> f )<tt> [virtual]</tt>
|
||
|
</h3><p>Sets the format used for displaying date/time values to <em>f</em>.
|
||
|
See the <a href="qdatatable.html#dateFormat-prop">"dateFormat"</a> property for details.
|
||
|
<h3 class=fn>void <a name="setFalseText"></a>QDataTable::setFalseText ( const <a href="qstring.html">QString</a> & falseText )<tt> [virtual]</tt>
|
||
|
</h3><p>Sets the text used to represent false values to <em>falseText</em>.
|
||
|
See the <a href="qdatatable.html#falseText-prop">"falseText"</a> property for details.
|
||
|
<h3 class=fn>void <a name="setFilter"></a>QDataTable::setFilter ( const <a href="qstring.html">QString</a> & filter )<tt> [virtual]</tt>
|
||
|
</h3><p>Sets the data filter for the data table to <em>filter</em>.
|
||
|
See the <a href="qdatatable.html#filter-prop">"filter"</a> property for details.
|
||
|
<h3 class=fn>void <a name="setNullText"></a>QDataTable::setNullText ( const <a href="qstring.html">QString</a> & nullText )<tt> [virtual]</tt>
|
||
|
</h3><p>Sets the text used to represent NULL values to <em>nullText</em>.
|
||
|
See the <a href="qdatatable.html#nullText-prop">"nullText"</a> property for details.
|
||
|
<h3 class=fn>void <a name="setSize"></a>QDataTable::setSize ( <a href="qsqlcursor.html">QSqlCursor</a> * sql )<tt> [protected]</tt>
|
||
|
</h3>
|
||
|
If the cursor's <em>sql</em> driver supports query sizes, the number of
|
||
|
rows in the table is set to the size of the query. Otherwise, the
|
||
|
table dynamically resizes itself as it is scrolled. If <em>sql</em> is
|
||
|
not active, it is made active by issuing a select() on the cursor
|
||
|
using the <em>sql</em> cursor's current filter and current sort.
|
||
|
|
||
|
<h3 class=fn>void <a name="setSort"></a>QDataTable::setSort ( const <a href="qstringlist.html">QStringList</a> & sort )<tt> [virtual]</tt>
|
||
|
</h3><p>Sets the data table's sort to <em>sort</em>.
|
||
|
See the <a href="qdatatable.html#sort-prop">"sort"</a> property for details.
|
||
|
<h3 class=fn>void <a name="setSort-2"></a>QDataTable::setSort ( const <a href="qsqlindex.html">QSqlIndex</a> & sort )<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
|
||
|
<p> Sets the sort to be applied to the displayed data to <em>sort</em>. If
|
||
|
there is no current cursor, nothing happens. A <a href="qsqlindex.html">QSqlIndex</a> contains
|
||
|
field names and their ordering (ASC or DESC); these are used to
|
||
|
compose the ORDER BY clause.
|
||
|
<p> <p>See also <a href="#sort-prop">sort</a>.
|
||
|
|
||
|
<h3 class=fn>void <a name="setSqlCursor"></a>QDataTable::setSqlCursor ( <a href="qsqlcursor.html">QSqlCursor</a> * cursor = 0, bool autoPopulate = FALSE, bool autoDelete = FALSE )<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Sets <em>cursor</em> as the data source for the table. To force the
|
||
|
display 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
|
||
|
the fields in the <em>cursor</em> record. If <em>autoDelete</em> is TRUE (the
|
||
|
default is FALSE), the table will take ownership of the <em>cursor</em>
|
||
|
and delete it when appropriate. If the <em>cursor</em> is read-only, the
|
||
|
table becomes read-only. The table adopts the cursor's driver's
|
||
|
definition for representing NULL values as strings.
|
||
|
<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>().
|
||
|
|
||
|
<h3 class=fn>void <a name="setTrueText"></a>QDataTable::setTrueText ( const <a href="qstring.html">QString</a> & trueText )<tt> [virtual]</tt>
|
||
|
</h3><p>Sets the text used to represent true values to <em>trueText</em>.
|
||
|
See the <a href="qdatatable.html#trueText-prop">"trueText"</a> property for details.
|
||
|
<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="sort"></a>QDataTable::sort () const
|
||
|
</h3><p>Returns the data table's sort.
|
||
|
See the <a href="qdatatable.html#sort-prop">"sort"</a> property for details.
|
||
|
<h3 class=fn>void <a name="sortAscending"></a>QDataTable::sortAscending ( int col )<tt> [virtual slot]</tt>
|
||
|
</h3>
|
||
|
Sorts column <em>col</em> in ascending order.
|
||
|
<p> <p>See also <a href="qtable.html#sorting-prop">sorting</a>.
|
||
|
|
||
|
<h3 class=fn>void <a name="sortColumn"></a>QDataTable::sortColumn ( int col, bool ascending = TRUE, bool wholeRows = FALSE )<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Sorts column <em>col</em> in ascending order if <em>ascending</em> is TRUE
|
||
|
(the default); otherwise sorts in descending order.
|
||
|
<p> The <em>wholeRows</em> parameter is ignored; QDataTable always sorts
|
||
|
whole rows by the specified column.
|
||
|
|
||
|
<p>Reimplemented from <a href="qtable.html#sortColumn">QTable</a>.
|
||
|
<h3 class=fn>void <a name="sortDescending"></a>QDataTable::sortDescending ( int col )<tt> [virtual slot]</tt>
|
||
|
</h3>
|
||
|
Sorts column <em>col</em> in descending order.
|
||
|
<p> <p>See also <a href="qtable.html#sorting-prop">sorting</a>.
|
||
|
|
||
|
<h3 class=fn><a href="qsqlcursor.html">QSqlCursor</a> * <a name="sqlCursor"></a>QDataTable::sqlCursor () const
|
||
|
</h3>
|
||
|
Returns the cursor used by the data table.
|
||
|
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QDataTable::text ( int row, int col ) const<tt> [virtual]</tt>
|
||
|
</h3>
|
||
|
Returns the text in cell <em>row</em>, <em>col</em>, or an empty string if the
|
||
|
cell is empty. If the cell's value is NULL then <a href="#nullText">nullText</a>() will be
|
||
|
returned. If the cell does not exist then <a href="qstring.html#QString-null">QString::null</a> is
|
||
|
returned.
|
||
|
|
||
|
<p>Reimplemented from <a href="qtable.html#text">QTable</a>.
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="trueText"></a>QDataTable::trueText () const
|
||
|
</h3><p>Returns the text used to represent true values.
|
||
|
See the <a href="qdatatable.html#trueText-prop">"trueText"</a> property for details.
|
||
|
<h3 class=fn>bool <a name="updateCurrent"></a>QDataTable::updateCurrent ()<tt> [virtual protected]</tt>
|
||
|
</h3>
|
||
|
For an editable table, issues an update using the cursor's edit
|
||
|
buffer. If there is no current cursor or there is no current
|
||
|
selection, nothing happens. If <a href="#confirmEdits">confirmEdits</a>() or <a href="#confirmUpdate">confirmUpdate</a>()
|
||
|
is TRUE, <a href="#confirmEdit">confirmEdit</a>() is called to confirm the update. Returns
|
||
|
TRUE if the update succeeded; otherwise returns FALSE.
|
||
|
<p> The underlying cursor must have a valid primary index to ensure
|
||
|
that a unique record is updated within the database otherwise the
|
||
|
database may be changed to an inconsistent state.
|
||
|
|
||
|
<h3 class=fn><a href="qvariant.html">QVariant</a> <a name="value"></a>QDataTable::value ( int row, int col ) const
|
||
|
</h3>
|
||
|
Returns the value in cell <em>row</em>, <em>col</em>, or an invalid value if
|
||
|
the cell does not exist or has no value.
|
||
|
|
||
|
<hr><h2>Property Documentation</h2>
|
||
|
<h3 class=fn>bool <a name="autoEdit-prop"></a>autoEdit</h3>
|
||
|
<p>This property holds whether the data table automatically applies edits.
|
||
|
<p>The default value for this property is TRUE. When the user begins
|
||
|
an insert or update in the table there are two possible outcomes
|
||
|
when they navigate to another record:
|
||
|
<p> <ol type=1>
|
||
|
<li> the insert or update is is performed -- this occurs if autoEdit is TRUE
|
||
|
<li> the insert or update is abandoned -- this occurs if autoEdit is FALSE
|
||
|
</ol>
|
||
|
|
||
|
<p>Set this property's value with <a href="#setAutoEdit">setAutoEdit</a>() and get this property's value with <a href="#autoEdit">autoEdit</a>().
|
||
|
<h3 class=fn>bool <a name="confirmCancels-prop"></a>confirmCancels</h3>
|
||
|
<p>This property holds whether the data table confirms cancel operations.
|
||
|
<p>If the confirmCancel property is TRUE, all cancels must be
|
||
|
confirmed by the user through a message box (this behavior can be
|
||
|
changed by overriding the <a href="#confirmCancel">confirmCancel</a>() function), otherwise all
|
||
|
cancels occur immediately. The default is FALSE.
|
||
|
<p> <p>See also <a href="#confirmEdits-prop">confirmEdits</a> and <a href="#confirmCancel">confirmCancel</a>().
|
||
|
|
||
|
<p>Set this property's value with <a href="#setConfirmCancels">setConfirmCancels</a>() and get this property's value with <a href="#confirmCancels">confirmCancels</a>().
|
||
|
<h3 class=fn>bool <a name="confirmDelete-prop"></a>confirmDelete</h3>
|
||
|
<p>This property holds whether the data table confirms delete operations.
|
||
|
<p>If the confirmDelete property is TRUE, all deletions must be
|
||
|
confirmed by the user through a message box (this behaviour can be
|
||
|
changed by overriding the <a href="#confirmEdit">confirmEdit</a>() function), otherwise all
|
||
|
delete operations occur immediately.
|
||
|
<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>.
|
||
|
|
||
|
<p>Set this property's value with <a href="#setConfirmDelete">setConfirmDelete</a>() and get this property's value with <a href="#confirmDelete">confirmDelete</a>().
|
||
|
<h3 class=fn>bool <a name="confirmEdits-prop"></a>confirmEdits</h3>
|
||
|
<p>This property holds whether the data table confirms edit operations.
|
||
|
<p>If the confirmEdits property is TRUE, the data table confirms all
|
||
|
edit operations (inserts, updates and deletes). Finer control of
|
||
|
edit 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>.
|
||
|
<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>.
|
||
|
|
||
|
<p>Set this property's value with <a href="#setConfirmEdits">setConfirmEdits</a>() and get this property's value with <a href="#confirmEdits">confirmEdits</a>().
|
||
|
<h3 class=fn>bool <a name="confirmInsert-prop"></a>confirmInsert</h3>
|
||
|
<p>This property holds whether the data table confirms insert operations.
|
||
|
<p>If the confirmInsert property is TRUE, all insertions must be
|
||
|
confirmed by the user through a message box (this behaviour can be
|
||
|
changed by overriding the <a href="#confirmEdit">confirmEdit</a>() function), otherwise all
|
||
|
insert operations occur immediately.
|
||
|
<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>.
|
||
|
|
||
|
<p>Set this property's value with <a href="#setConfirmInsert">setConfirmInsert</a>() and get this property's value with <a href="#confirmInsert">confirmInsert</a>().
|
||
|
<h3 class=fn>bool <a name="confirmUpdate-prop"></a>confirmUpdate</h3>
|
||
|
<p>This property holds whether the data table confirms update operations.
|
||
|
<p>If the confirmUpdate property is TRUE, all updates must be
|
||
|
confirmed by the user through a message box (this behaviour can be
|
||
|
changed by overriding the <a href="#confirmEdit">confirmEdit</a>() function), otherwise all
|
||
|
update operations occur immediately.
|
||
|
<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>.
|
||
|
|
||
|
<p>Set this property's value with <a href="#setConfirmUpdate">setConfirmUpdate</a>() and get this property's value with <a href="#confirmUpdate">confirmUpdate</a>().
|
||
|
<h3 class=fn><a href="qt.html#DateFormat-enum">DateFormat</a> <a name="dateFormat-prop"></a>dateFormat</h3>
|
||
|
<p>This property holds the format used for displaying date/time values.
|
||
|
<p>The dateFormat property is used for displaying date/time values in
|
||
|
the table. The default value is <a href="qt.html#DateFormat-enum">Qt::LocalDate</a>.
|
||
|
|
||
|
<p>Set this property's value with <a href="#setDateFormat">setDateFormat</a>() and get this property's value with <a href="#dateFormat">dateFormat</a>().
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="falseText-prop"></a>falseText</h3>
|
||
|
<p>This property holds the text used to represent false values.
|
||
|
<p>The falseText property will be used to represent NULL values in
|
||
|
the table. The default value is "False".
|
||
|
|
||
|
<p>Set this property's value with <a href="#setFalseText">setFalseText</a>() and get this property's value with <a href="#falseText">falseText</a>().
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="filter-prop"></a>filter</h3>
|
||
|
<p>This property holds the data filter for the data table.
|
||
|
<p>The filter applies to the data shown in the table. To view data
|
||
|
with a new filter, use <a href="#refresh">refresh</a>(). A filter string is an SQL WHERE
|
||
|
clause without the WHERE keyword.
|
||
|
<p> There is no default filter.
|
||
|
<p> <p>See also <a href="#sort-prop">sort</a>.
|
||
|
|
||
|
<p>
|
||
|
<p>Set this property's value with <a href="#setFilter">setFilter</a>() and get this property's value with <a href="#filter">filter</a>().
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="nullText-prop"></a>nullText</h3>
|
||
|
<p>This property holds the text used to represent NULL values.
|
||
|
<p>The nullText property will be used to represent NULL values in the
|
||
|
table. The default value is provided by the cursor's driver.
|
||
|
|
||
|
<p>Set this property's value with <a href="#setNullText">setNullText</a>() and get this property's value with <a href="#nullText">nullText</a>().
|
||
|
<h3 class=fn>int <a name="numCols-prop"></a>numCols</h3>
|
||
|
<p>This property holds the number of columns in the table.
|
||
|
<p>
|
||
|
<p>Get this property's value with <a href="#numCols">numCols</a>().
|
||
|
<h3 class=fn>int <a name="numRows-prop"></a>numRows</h3>
|
||
|
<p>This property holds the number of rows in the table.
|
||
|
<p>
|
||
|
<p>Get this property's value with <a href="#numRows">numRows</a>().
|
||
|
<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="sort-prop"></a>sort</h3>
|
||
|
<p>This property holds the data table's sort.
|
||
|
<p>The table's sort affects the order in which data records are
|
||
|
displayed in the table. To apply a sort, use <a href="#refresh">refresh</a>().
|
||
|
<p> When examining the sort property, a string list is returned with
|
||
|
each item having the form 'fieldname order' (e.g., 'id ASC',
|
||
|
'surname DESC').
|
||
|
<p> There is no default sort.
|
||
|
<p> Note that if you want to iterate over the sort list, you should
|
||
|
iterate over a copy, e.g.
|
||
|
<pre>
|
||
|
<a href="qstringlist.html">QStringList</a> list = myDataTable.sort();
|
||
|
QStringList::Iterator it = list.<a href="qvaluelist.html#begin">begin</a>();
|
||
|
while( it != list.<a href="qvaluelist.html#end">end</a>() ) {
|
||
|
myProcessing( *it );
|
||
|
++it;
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<p> <p>See also <a href="#filter-prop">filter</a> and <a href="#refresh">refresh</a>().
|
||
|
|
||
|
<p>Set this property's value with <a href="#setSort">setSort</a>() and get this property's value with <a href="#sort">sort</a>().
|
||
|
<h3 class=fn><a href="qstring.html">QString</a> <a name="trueText-prop"></a>trueText</h3>
|
||
|
<p>This property holds the text used to represent true values.
|
||
|
<p>The trueText property will be used to represent NULL values in the
|
||
|
table. The default value is "True".
|
||
|
|
||
|
<p>Set this property's value with <a href="#setTrueText">setTrueText</a>() and get this property's value with <a href="#trueText">trueText</a>().
|
||
|
<!-- eof -->
|
||
|
<hr><p>
|
||
|
This file is part of the <a href="index.html">Qt toolkit</a>.
|
||
|
Copyright © 1995-2007
|
||
|
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
|
||
|
<table width=100% cellspacing=0 border=0><tr>
|
||
|
<td>Copyright © 2007
|
||
|
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
||
|
<td align=right><div align=right>Qt 3.3.8</div>
|
||
|
</table></div></address></body>
|
||
|
</html>
|