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