source: trunk/doc/html/qtable.html@ 203

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

reference documentation added

File size: 100.1 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/table/qtable.cpp:1659 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QTable Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QTable Class Reference<br><small>[<a href="table.html">table module</a>]</small></h1>
33
34<p>The QTable class provides a flexible editable table widget.
35<a href="#details">More...</a>
36<p><tt>#include &lt;<a href="qtable-h.html">qtable.h</a>&gt;</tt>
37<p>Inherits <a href="qscrollview.html">QScrollView</a>.
38<p>Inherited by <a href="qdatatable.html">QDataTable</a>.
39<p><a href="qtable-members.html">List of all member functions.</a>
40<h2>Public Members</h2>
41<ul>
42<li class=fn><a href="#QTable"><b>QTable</b></a> ( QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
43<li class=fn><a href="#QTable-2"><b>QTable</b></a> ( int&nbsp;numRows, int&nbsp;numCols, QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
44<li class=fn><a href="#~QTable"><b>~QTable</b></a> ()</li>
45<li class=fn>QHeader * <a href="#horizontalHeader"><b>horizontalHeader</b></a> () const</li>
46<li class=fn>QHeader * <a href="#verticalHeader"><b>verticalHeader</b></a> () const</li>
47<li class=fn>enum <a href="#SelectionMode-enum"><b>SelectionMode</b></a> { Single, Multi, SingleRow, MultiRow, NoSelection }</li>
48<li class=fn>virtual void <a href="#setSelectionMode"><b>setSelectionMode</b></a> ( SelectionMode&nbsp;mode )</li>
49<li class=fn>SelectionMode <a href="#selectionMode"><b>selectionMode</b></a> () const</li>
50<li class=fn>virtual void <a href="#setItem"><b>setItem</b></a> ( int&nbsp;row, int&nbsp;col, QTableItem&nbsp;*&nbsp;item )</li>
51<li class=fn>virtual void <a href="#setText"><b>setText</b></a> ( int&nbsp;row, int&nbsp;col, const&nbsp;QString&nbsp;&amp;&nbsp;text )</li>
52<li class=fn>virtual void <a href="#setPixmap"><b>setPixmap</b></a> ( int&nbsp;row, int&nbsp;col, const&nbsp;QPixmap&nbsp;&amp;&nbsp;pix )</li>
53<li class=fn>virtual QTableItem * <a href="#item"><b>item</b></a> ( int&nbsp;row, int&nbsp;col ) const</li>
54<li class=fn>virtual QString <a href="#text"><b>text</b></a> ( int&nbsp;row, int&nbsp;col ) const</li>
55<li class=fn>virtual QPixmap <a href="#pixmap"><b>pixmap</b></a> ( int&nbsp;row, int&nbsp;col ) const</li>
56<li class=fn>virtual void <a href="#clearCell"><b>clearCell</b></a> ( int&nbsp;row, int&nbsp;col )</li>
57<li class=fn>virtual QRect <a href="#cellGeometry"><b>cellGeometry</b></a> ( int&nbsp;row, int&nbsp;col ) const</li>
58<li class=fn>virtual int <a href="#columnWidth"><b>columnWidth</b></a> ( int&nbsp;col ) const</li>
59<li class=fn>virtual int <a href="#rowHeight"><b>rowHeight</b></a> ( int&nbsp;row ) const</li>
60<li class=fn>virtual int <a href="#columnPos"><b>columnPos</b></a> ( int&nbsp;col ) const</li>
61<li class=fn>virtual int <a href="#rowPos"><b>rowPos</b></a> ( int&nbsp;row ) const</li>
62<li class=fn>virtual int <a href="#columnAt"><b>columnAt</b></a> ( int&nbsp;x ) const</li>
63<li class=fn>virtual int <a href="#rowAt"><b>rowAt</b></a> ( int&nbsp;y ) const</li>
64<li class=fn>virtual int <a href="#numRows"><b>numRows</b></a> () const</li>
65<li class=fn>virtual int <a href="#numCols"><b>numCols</b></a> () const</li>
66<li class=fn>void <a href="#updateCell"><b>updateCell</b></a> ( int&nbsp;row, int&nbsp;col )</li>
67<li class=fn>int <a href="#currentRow"><b>currentRow</b></a> () const</li>
68<li class=fn>int <a href="#currentColumn"><b>currentColumn</b></a> () const</li>
69<li class=fn>void <a href="#ensureCellVisible"><b>ensureCellVisible</b></a> ( int&nbsp;row, int&nbsp;col )</li>
70<li class=fn>bool <a href="#isSelected"><b>isSelected</b></a> ( int&nbsp;row, int&nbsp;col ) const</li>
71<li class=fn>bool <a href="#isRowSelected"><b>isRowSelected</b></a> ( int&nbsp;row, bool&nbsp;full = FALSE ) const</li>
72<li class=fn>bool <a href="#isColumnSelected"><b>isColumnSelected</b></a> ( int&nbsp;col, bool&nbsp;full = FALSE ) const</li>
73<li class=fn>int <a href="#numSelections"><b>numSelections</b></a> () const</li>
74<li class=fn>QTableSelection <a href="#selection"><b>selection</b></a> ( int&nbsp;num ) const</li>
75<li class=fn>virtual int <a href="#addSelection"><b>addSelection</b></a> ( const&nbsp;QTableSelection&nbsp;&amp;&nbsp;s )</li>
76<li class=fn>virtual void <a href="#removeSelection"><b>removeSelection</b></a> ( const&nbsp;QTableSelection&nbsp;&amp;&nbsp;s )</li>
77<li class=fn>virtual void <a href="#removeSelection-2"><b>removeSelection</b></a> ( int&nbsp;num )</li>
78<li class=fn>virtual int <a href="#currentSelection"><b>currentSelection</b></a> () const</li>
79<li class=fn>void <a href="#selectCells"><b>selectCells</b></a> ( int&nbsp;start_row, int&nbsp;start_col, int&nbsp;end_row, int&nbsp;end_col )</li>
80<li class=fn>void <a href="#selectRow"><b>selectRow</b></a> ( int&nbsp;row )</li>
81<li class=fn>void <a href="#selectColumn"><b>selectColumn</b></a> ( int&nbsp;col )</li>
82<li class=fn>bool <a href="#showGrid"><b>showGrid</b></a> () const</li>
83<li class=fn>bool <a href="#columnMovingEnabled"><b>columnMovingEnabled</b></a> () const</li>
84<li class=fn>bool <a href="#rowMovingEnabled"><b>rowMovingEnabled</b></a> () const</li>
85<li class=fn>virtual void <a href="#sortColumn"><b>sortColumn</b></a> ( int&nbsp;col, bool&nbsp;ascending = TRUE, bool&nbsp;wholeRows = FALSE )</li>
86<li class=fn>bool <a href="#sorting"><b>sorting</b></a> () const</li>
87<li class=fn>virtual void <a href="#takeItem"><b>takeItem</b></a> ( QTableItem&nbsp;*&nbsp;i )</li>
88<li class=fn>virtual void <a href="#setCellWidget"><b>setCellWidget</b></a> ( int&nbsp;row, int&nbsp;col, QWidget&nbsp;*&nbsp;e )</li>
89<li class=fn>virtual QWidget * <a href="#cellWidget"><b>cellWidget</b></a> ( int&nbsp;row, int&nbsp;col ) const</li>
90<li class=fn>virtual void <a href="#clearCellWidget"><b>clearCellWidget</b></a> ( int&nbsp;row, int&nbsp;col )</li>
91<li class=fn>virtual QRect <a href="#cellRect"><b>cellRect</b></a> ( int&nbsp;row, int&nbsp;col ) const</li>
92<li class=fn>virtual void <a href="#paintCell-2"><b>paintCell</b></a> ( QPainter&nbsp;*&nbsp;p, int&nbsp;row, int&nbsp;col, const&nbsp;QRect&nbsp;&amp;&nbsp;cr, bool&nbsp;selected )</li>
93<li class=fn>virtual void <a href="#paintCell"><b>paintCell</b></a> ( QPainter&nbsp;*&nbsp;p, int&nbsp;row, int&nbsp;col, const&nbsp;QRect&nbsp;&amp;&nbsp;cr, bool&nbsp;selected, const&nbsp;QColorGroup&nbsp;&amp;&nbsp;cg )</li>
94<li class=fn>virtual void <a href="#paintFocus"><b>paintFocus</b></a> ( QPainter&nbsp;*&nbsp;p, const&nbsp;QRect&nbsp;&amp;&nbsp;cr )</li>
95<li class=fn>bool <a href="#isReadOnly"><b>isReadOnly</b></a> () const</li>
96<li class=fn>bool <a href="#isRowReadOnly"><b>isRowReadOnly</b></a> ( int&nbsp;row ) const</li>
97<li class=fn>bool <a href="#isColumnReadOnly"><b>isColumnReadOnly</b></a> ( int&nbsp;col ) const</li>
98<li class=fn>void <a href="#repaintSelections"><b>repaintSelections</b></a> ()</li>
99<li class=fn>enum <a href="#FocusStyle-enum"><b>FocusStyle</b></a> { FollowStyle, SpreadSheet }</li>
100<li class=fn>virtual void <a href="#setFocusStyle"><b>setFocusStyle</b></a> ( FocusStyle&nbsp;fs )</li>
101<li class=fn>FocusStyle <a href="#focusStyle"><b>focusStyle</b></a> () const</li>
102<li class=fn>void <a href="#updateHeaderStates"><b>updateHeaderStates</b></a> ()</li>
103</ul>
104<h2>Public Slots</h2>
105<ul>
106<li class=fn>virtual void <a href="#setNumRows"><b>setNumRows</b></a> ( int&nbsp;r )</li>
107<li class=fn>virtual void <a href="#setNumCols"><b>setNumCols</b></a> ( int&nbsp;r )</li>
108<li class=fn>virtual void <a href="#setShowGrid"><b>setShowGrid</b></a> ( bool&nbsp;b )</li>
109<li class=fn>virtual void <a href="#hideRow"><b>hideRow</b></a> ( int&nbsp;row )</li>
110<li class=fn>virtual void <a href="#hideColumn"><b>hideColumn</b></a> ( int&nbsp;col )</li>
111<li class=fn>virtual void <a href="#showRow"><b>showRow</b></a> ( int&nbsp;row )</li>
112<li class=fn>virtual void <a href="#showColumn"><b>showColumn</b></a> ( int&nbsp;col )</li>
113<li class=fn>bool <a href="#isRowHidden"><b>isRowHidden</b></a> ( int&nbsp;row ) const</li>
114<li class=fn>bool <a href="#isColumnHidden"><b>isColumnHidden</b></a> ( int&nbsp;col ) const</li>
115<li class=fn>virtual void <a href="#setColumnWidth"><b>setColumnWidth</b></a> ( int&nbsp;col, int&nbsp;w )</li>
116<li class=fn>virtual void <a href="#setRowHeight"><b>setRowHeight</b></a> ( int&nbsp;row, int&nbsp;h )</li>
117<li class=fn>virtual void <a href="#adjustColumn"><b>adjustColumn</b></a> ( int&nbsp;col )</li>
118<li class=fn>virtual void <a href="#adjustRow"><b>adjustRow</b></a> ( int&nbsp;row )</li>
119<li class=fn>virtual void <a href="#setColumnStretchable"><b>setColumnStretchable</b></a> ( int&nbsp;col, bool&nbsp;stretch )</li>
120<li class=fn>virtual void <a href="#setRowStretchable"><b>setRowStretchable</b></a> ( int&nbsp;row, bool&nbsp;stretch )</li>
121<li class=fn>bool <a href="#isColumnStretchable"><b>isColumnStretchable</b></a> ( int&nbsp;col ) const</li>
122<li class=fn>bool <a href="#isRowStretchable"><b>isRowStretchable</b></a> ( int&nbsp;row ) const</li>
123<li class=fn>virtual void <a href="#setSorting"><b>setSorting</b></a> ( bool&nbsp;b )</li>
124<li class=fn>virtual void <a href="#swapRows"><b>swapRows</b></a> ( int&nbsp;row1, int&nbsp;row2, bool&nbsp;swapHeader = FALSE )</li>
125<li class=fn>virtual void <a href="#swapColumns"><b>swapColumns</b></a> ( int&nbsp;col1, int&nbsp;col2, bool&nbsp;swapHeader = FALSE )</li>
126<li class=fn>virtual void <a href="#swapCells"><b>swapCells</b></a> ( int&nbsp;row1, int&nbsp;col1, int&nbsp;row2, int&nbsp;col2 )</li>
127<li class=fn>virtual void <a href="#setLeftMargin"><b>setLeftMargin</b></a> ( int&nbsp;m )</li>
128<li class=fn>virtual void <a href="#setTopMargin"><b>setTopMargin</b></a> ( int&nbsp;m )</li>
129<li class=fn>virtual void <a href="#setCurrentCell"><b>setCurrentCell</b></a> ( int&nbsp;row, int&nbsp;col )</li>
130<li class=fn>void <a href="#clearSelection"><b>clearSelection</b></a> ( bool&nbsp;repaint = TRUE )</li>
131<li class=fn>virtual void <a href="#setColumnMovingEnabled"><b>setColumnMovingEnabled</b></a> ( bool&nbsp;b )</li>
132<li class=fn>virtual void <a href="#setRowMovingEnabled"><b>setRowMovingEnabled</b></a> ( bool&nbsp;b )</li>
133<li class=fn>virtual void <a href="#setReadOnly"><b>setReadOnly</b></a> ( bool&nbsp;b )</li>
134<li class=fn>virtual void <a href="#setRowReadOnly"><b>setRowReadOnly</b></a> ( int&nbsp;row, bool&nbsp;ro )</li>
135<li class=fn>virtual void <a href="#setColumnReadOnly"><b>setColumnReadOnly</b></a> ( int&nbsp;col, bool&nbsp;ro )</li>
136<li class=fn>virtual void <a href="#setDragEnabled"><b>setDragEnabled</b></a> ( bool&nbsp;b )</li>
137<li class=fn>bool <a href="#dragEnabled"><b>dragEnabled</b></a> () const</li>
138<li class=fn>virtual void <a href="#insertRows"><b>insertRows</b></a> ( int&nbsp;row, int&nbsp;count = 1 )</li>
139<li class=fn>virtual void <a href="#insertColumns"><b>insertColumns</b></a> ( int&nbsp;col, int&nbsp;count = 1 )</li>
140<li class=fn>virtual void <a href="#removeRow"><b>removeRow</b></a> ( int&nbsp;row )</li>
141<li class=fn>virtual void <a href="#removeRows"><b>removeRows</b></a> ( const&nbsp;QMemArray&lt;int&gt;&nbsp;&amp;&nbsp;rows )</li>
142<li class=fn>virtual void <a href="#removeColumn"><b>removeColumn</b></a> ( int&nbsp;col )</li>
143<li class=fn>virtual void <a href="#removeColumns"><b>removeColumns</b></a> ( const&nbsp;QMemArray&lt;int&gt;&nbsp;&amp;&nbsp;cols )</li>
144<li class=fn>virtual void <a href="#editCell"><b>editCell</b></a> ( int&nbsp;row, int&nbsp;col, bool&nbsp;replace = FALSE )</li>
145<li class=fn>void <a href="#setRowLabels"><b>setRowLabels</b></a> ( const&nbsp;QStringList&nbsp;&amp;&nbsp;labels )</li>
146<li class=fn>void <a href="#setColumnLabels"><b>setColumnLabels</b></a> ( const&nbsp;QStringList&nbsp;&amp;&nbsp;labels )</li>
147</ul>
148<h2>Signals</h2>
149<ul>
150<li class=fn>void <a href="#currentChanged"><b>currentChanged</b></a> ( int&nbsp;row, int&nbsp;col )</li>
151<li class=fn>void <a href="#clicked"><b>clicked</b></a> ( int&nbsp;row, int&nbsp;col, int&nbsp;button, const&nbsp;QPoint&nbsp;&amp;&nbsp;mousePos )</li>
152<li class=fn>void <a href="#doubleClicked"><b>doubleClicked</b></a> ( int&nbsp;row, int&nbsp;col, int&nbsp;button, const&nbsp;QPoint&nbsp;&amp;&nbsp;mousePos )</li>
153<li class=fn>void <a href="#pressed"><b>pressed</b></a> ( int&nbsp;row, int&nbsp;col, int&nbsp;button, const&nbsp;QPoint&nbsp;&amp;&nbsp;mousePos )</li>
154<li class=fn>void <a href="#selectionChanged"><b>selectionChanged</b></a> ()</li>
155<li class=fn>void <a href="#valueChanged"><b>valueChanged</b></a> ( int&nbsp;row, int&nbsp;col )</li>
156<li class=fn>void <a href="#contextMenuRequested"><b>contextMenuRequested</b></a> ( int&nbsp;row, int&nbsp;col, const&nbsp;QPoint&nbsp;&amp;&nbsp;pos )</li>
157<li class=fn>void <a href="#dropped"><b>dropped</b></a> ( QDropEvent&nbsp;*&nbsp;e )</li>
158</ul>
159<h2>Properties</h2>
160<ul>
161<li class=fn>bool <a href="#columnMovingEnabled-prop"><b>columnMovingEnabled</b></a>&nbsp;- whether columns can be moved by the user</li>
162<li class=fn>FocusStyle <a href="#focusStyle-prop"><b>focusStyle</b></a>&nbsp;- how the current (focus) cell is drawn</li>
163<li class=fn>int <a href="#numCols-prop"><b>numCols</b></a>&nbsp;- the number of columns in the table</li>
164<li class=fn>int <a href="#numRows-prop"><b>numRows</b></a>&nbsp;- the number of rows in the table</li>
165<li class=fn>int <a href="#numSelections-prop"><b>numSelections</b></a>&nbsp;- the number of selections &nbsp;<em>(read only)</em></li>
166<li class=fn>bool <a href="#readOnly-prop"><b>readOnly</b></a>&nbsp;- whether the table is read-only</li>
167<li class=fn>bool <a href="#rowMovingEnabled-prop"><b>rowMovingEnabled</b></a>&nbsp;- whether rows can be moved by the user</li>
168<li class=fn>SelectionMode <a href="#selectionMode-prop"><b>selectionMode</b></a>&nbsp;- the current selection mode</li>
169<li class=fn>bool <a href="#showGrid-prop"><b>showGrid</b></a>&nbsp;- whether the table's grid is displayed</li>
170<li class=fn>bool <a href="#sorting-prop"><b>sorting</b></a>&nbsp;- whether a click on the header of a column sorts that column</li>
171</ul>
172<h2>Protected Members</h2>
173<ul>
174<li class=fn>enum <a href="#EditMode-enum"><b>EditMode</b></a> { NotEditing, Editing, Replacing }</li>
175<li class=fn>virtual void <a href="#drawContents"><b>drawContents</b></a> ( QPainter&nbsp;*&nbsp;p, int&nbsp;cx, int&nbsp;cy, int&nbsp;cw, int&nbsp;ch )</li>
176<li class=fn>void <a href="#setEditMode"><b>setEditMode</b></a> ( EditMode&nbsp;mode, int&nbsp;row, int&nbsp;col )</li>
177<li class=fn>virtual void <a href="#contentsDragEnterEvent"><b>contentsDragEnterEvent</b></a> ( QDragEnterEvent&nbsp;*&nbsp;e )</li>
178<li class=fn>virtual void <a href="#contentsDragMoveEvent"><b>contentsDragMoveEvent</b></a> ( QDragMoveEvent&nbsp;*&nbsp;e )</li>
179<li class=fn>virtual void <a href="#contentsDragLeaveEvent"><b>contentsDragLeaveEvent</b></a> ( QDragLeaveEvent&nbsp;*&nbsp;e )</li>
180<li class=fn>virtual void <a href="#contentsDropEvent"><b>contentsDropEvent</b></a> ( QDropEvent&nbsp;*&nbsp;e )</li>
181<li class=fn>virtual QDragObject * <a href="#dragObject"><b>dragObject</b></a> ()</li>
182<li class=fn>virtual void <a href="#startDrag"><b>startDrag</b></a> ()</li>
183<li class=fn>virtual void <a href="#paintEmptyArea"><b>paintEmptyArea</b></a> ( QPainter&nbsp;*&nbsp;p, int&nbsp;cx, int&nbsp;cy, int&nbsp;cw, int&nbsp;ch )</li>
184<li class=fn>virtual void <a href="#activateNextCell"><b>activateNextCell</b></a> ()</li>
185<li class=fn>virtual QWidget * <a href="#createEditor"><b>createEditor</b></a> ( int&nbsp;row, int&nbsp;col, bool&nbsp;initFromCell ) const</li>
186<li class=fn>virtual void <a href="#setCellContentFromEditor"><b>setCellContentFromEditor</b></a> ( int&nbsp;row, int&nbsp;col )</li>
187<li class=fn>virtual QWidget * <a href="#beginEdit"><b>beginEdit</b></a> ( int&nbsp;row, int&nbsp;col, bool&nbsp;replace )</li>
188<li class=fn>virtual void <a href="#endEdit"><b>endEdit</b></a> ( int&nbsp;row, int&nbsp;col, bool&nbsp;accept, bool&nbsp;replace )</li>
189<li class=fn>virtual void <a href="#resizeData"><b>resizeData</b></a> ( int&nbsp;len )</li>
190<li class=fn>virtual void <a href="#insertWidget"><b>insertWidget</b></a> ( int&nbsp;row, int&nbsp;col, QWidget&nbsp;*&nbsp;w )</li>
191<li class=fn>int <a href="#indexOf"><b>indexOf</b></a> ( int&nbsp;row, int&nbsp;col ) const</li>
192<li class=fn>bool <a href="#isEditing"><b>isEditing</b></a> () const</li>
193<li class=fn>EditMode <a href="#editMode"><b>editMode</b></a> () const</li>
194<li class=fn>int <a href="#currEditRow"><b>currEditRow</b></a> () const</li>
195<li class=fn>int <a href="#currEditCol"><b>currEditCol</b></a> () const</li>
196</ul>
197<h2>Protected Slots</h2>
198<ul>
199<li class=fn>virtual void <a href="#columnWidthChanged"><b>columnWidthChanged</b></a> ( int&nbsp;col )</li>
200<li class=fn>virtual void <a href="#rowHeightChanged"><b>rowHeightChanged</b></a> ( int&nbsp;row )</li>
201<li class=fn>virtual void <a href="#columnIndexChanged"><b>columnIndexChanged</b></a> ( int&nbsp;section, int&nbsp;fromIndex, int&nbsp;toIndex )</li>
202<li class=fn>virtual void <a href="#rowIndexChanged"><b>rowIndexChanged</b></a> ( int&nbsp;section, int&nbsp;fromIndex, int&nbsp;toIndex )</li>
203<li class=fn>virtual void <a href="#columnClicked"><b>columnClicked</b></a> ( int&nbsp;col )</li>
204</ul>
205<hr><a name="details"></a><h2>Detailed Description</h2>
206
207
208The QTable class provides a flexible editable table widget.
209
210<p>
211
212
213<p> QTable is easy to use, although it does have a large API because
214of the comprehensive functionality that it provides. QTable
215includes functions for manipulating <a href="#headers">headers</a>, <a href="#columnsrows">rows and columns</a>,
216<a href="#cells">cells</a> and <a href="#selections">selections</a>. QTable also provides in-place editing and
217<a href="dnd.html">drag and drop</a>, as well as a useful set of
218<a href="#signals">signals</a>. QTable efficiently supports very
219large tables, for example, tables one million by one million cells
220are perfectly possible. QTable is economical with memory, using
221none for unused cells.
222<p> <pre>
223 QTable *table = new QTable( 100, 250, this );
224 table-&gt;<a href="#setPixmap">setPixmap</a>( 3, 2, pix );
225 table-&gt;<a href="#setText">setText</a>( 3, 2, "A pixmap" );
226 </pre>
227
228<p> The first line constructs the table specifying its size in rows
229and columns. We then insert a pixmap and some text into the <em>same</em> <a href="#cells">cell</a>, with the pixmap appearing to the
230left of the text. QTable cells can be populated with
231<a href="qtableitem.html">QTableItem</a>s, <a href="qcombotableitem.html">QComboTableItem</a>s or by <a href="qchecktableitem.html">QCheckTableItem</a>s.
232By default a vertical header appears at the left of the table
233showing row numbers and a horizontal header appears at the top of
234the table showing column numbers. (The numbers displayed start at
2351, although row and column numbers within QTable begin at 0.)
236<p> If you want to use mouse tracking call <a href="qwidget.html#setMouseTracking">setMouseTracking</a>( TRUE ) on
237the <em>viewport</em>; (see <a href="qscrollview.html#allviews">QScrollView</a>).
238<p> <center><img src="qtableitems.png" alt="Table Items"></center>
239<p> <a name="headers"></a>
240<h3> Headers
241</h3>
242<a name="1"></a><p> QTable supports a header column, e.g. to display row numbers, and
243a header row, e.g to display column titles. To set row or column
244labels use <a href="qheader.html#setLabel">QHeader::setLabel</a>() on the pointers returned by
245<a href="#verticalHeader">verticalHeader</a>() and <a href="#horizontalHeader">horizontalHeader</a>() respectively. The vertical
246header is displayed within the table's left margin whose width is
247set with <a href="#setLeftMargin">setLeftMargin</a>(). The horizontal header is displayed
248within the table's top margin whose height is set with
249<a href="#setTopMargin">setTopMargin</a>(). The table's grid can be switched off with
250<a href="#setShowGrid">setShowGrid</a>(). If you want to hide a horizontal header call
251<a href="qwidget.html#hide">hide</a>(), and call setTopMargin( 0 ) so that the area the header
252would have occupied is reduced to zero size.
253<p> Header labels are indexed via their section numbers. Note that the
254default behavior of <a href="qheader.html">QHeader</a> regarding section numbers is overriden
255for QTable. See the explanation below in the Rows and Columns
256section in the discussion of moving columns and rows.
257<p> <a name="columnsrows"></a>
258<h3> Rows and Columns
259</h3>
260<a name="1-1"></a><p> Row and column sizes are set with <a href="#setRowHeight">setRowHeight</a>() and
261<a href="#setColumnWidth">setColumnWidth</a>(). If you want a row high enough to show the
262tallest item in its entirety, use <a href="#adjustRow">adjustRow</a>(). Similarly, to make
263a column wide enough to show the widest item use <a href="#adjustColumn">adjustColumn</a>().
264If you want the row height and column width to adjust
265automatically as the height and width of the table changes use
266<a href="#setRowStretchable">setRowStretchable</a>() and <a href="#setColumnStretchable">setColumnStretchable</a>().
267<p> Rows and columns can be hidden and shown with <a href="#hideRow">hideRow</a>(),
268<a href="#hideColumn">hideColumn</a>(), <a href="#showRow">showRow</a>() and <a href="#showColumn">showColumn</a>(). New rows and columns are
269inserted using <a href="#insertRows">insertRows</a>() and <a href="#insertColumns">insertColumns</a>(). Additional rows
270and columns are added at the bottom (rows) or right (columns) if
271you set <a href="#setNumRows">setNumRows</a>() or <a href="#setNumCols">setNumCols</a>() to be larger than <a href="#numRows">numRows</a>()
272or <a href="#numCols">numCols</a>(). Existing rows and columns are removed with
273<a href="#removeRow">removeRow</a>() and <a href="#removeColumn">removeColumn</a>(). Multiple rows and columns can be
274removed with <a href="#removeRows">removeRows</a>() and <a href="#removeColumns">removeColumns</a>().
275<p> Rows and columns can be set to be moveable using
276<a href="#rowMovingEnabled">rowMovingEnabled</a>() and <a href="#columnMovingEnabled">columnMovingEnabled</a>(). The user can drag
277them to reorder them holding down the Ctrl key and dragging the
278mouse. For performance reasons, the default behavior of <a href="qheader.html">QHeader</a>
279section numbers is overridden by QTable. Currently in QTable, when
280a row or column is dragged and reordered, the section number is
281also changed to its new position. Therefore, there is no
282difference between the section and the index fields in QHeader.
283The QTable QHeader classes do not provide a mechanism for indexing
284independently of the user interface ordering.
285<p> The table can be sorted using <a href="#sortColumn">sortColumn</a>(). Users can sort a
286column by clicking its header if <a href="#setSorting">setSorting</a>() is set to TRUE. Rows
287can be swapped with <a href="#swapRows">swapRows</a>(), columns with <a href="#swapColumns">swapColumns</a>() and
288cells with <a href="#swapCells">swapCells</a>().
289<p> For editable tables (see <a href="#setReadOnly">setReadOnly</a>()) you can set the read-only
290property of individual rows and columns with <a href="#setRowReadOnly">setRowReadOnly</a>() and
291<a href="#setColumnReadOnly">setColumnReadOnly</a>(). (Whether a cell is editable or read-only
292depends on these settings and the cell's <a href="qtableitem.html#wheneditable">QTableItem::EditType</a>.)
293<p> The row and column which have the focus are returned by
294<a href="#currentRow">currentRow</a>() and <a href="#currentColumn">currentColumn</a>() respectively.
295<p> Although many QTable functions operate in terms of rows and
296columns the <a href="#indexOf">indexOf</a>() function returns a single integer
297identifying a particular cell.
298<p> <a name="cells"></a>
299<h3> Cells
300</h3>
301<a name="1-2"></a><p> All of a QTable's cells are empty when the table is constructed.
302<p> There are two approaches to populating the table's cells. The
303first and simplest approach is to use QTableItems or <a href="qtableitem.html">QTableItem</a>
304subclasses. The second approach doesn't use QTableItems at all
305which is useful for very large sparse tables but requires you to
306reimplement a number of functions. We'll look at each approach in
307turn.
308<p> To put a string in a cell use <a href="#setText">setText</a>(). This function will create
309a new QTableItem for the cell if one doesn't already exist, and
310displays the text in it. By default the table item's widget will
311be a <a href="qlineedit.html">QLineEdit</a>. A pixmap may be put in a cell with <a href="#setPixmap">setPixmap</a>(),
312which also creates a table item if required. A cell may contain <em>both</em> a pixmap and text; the pixmap is displayed to the left of the
313text. Another approach is to construct a QTableItem or QTableItem
314subclass, set its properties, then insert it into a cell with
315<a href="#setItem">setItem</a>().
316<p> If you want cells which contain comboboxes use the <a href="qcombotableitem.html">QComboTableItem</a>
317class. Similarly if you require cells containing checkboxes use
318the <a href="qchecktableitem.html">QCheckTableItem</a> class. These table items look and behave just
319like the combobox or checkbox widgets but consume far less memory.
320<p>
321
322<pre> for ( int j = 0; j &lt; numRows; ++j )
323 <a name="x2445"></a> table.<a href="#setItem">setItem</a>( j, 1, new <a href="qchecktableitem.html">QCheckTableItem</a>( &amp;table, "Check me" ) );
324</pre>In the example above we create a column of QCheckTableItems and
325insert them into the table using setItem().
326<p> QTable takes ownership of its QTableItems and will delete them
327when the table itself is destroyed. You can take ownership of a
328table item using <a href="#takeItem">takeItem</a>() which you use to move a cell's
329contents from one cell to another, either within the same table,
330or from one table to another. (See also, <a href="#swapCells">swapCells</a>()).
331<p> In-place editing of the text in QTableItems, and the values in
332QComboTableItems and QCheckTableItems works automatically. Cells
333may be editable or read-only, see <a href="qtableitem.html#wheneditable">QTableItem::EditType</a>. If you
334want fine control over editing see <a href="#beginEdit">beginEdit</a>() and <a href="#endEdit">endEdit</a>().
335<p> The contents of a cell can be retrieved as a <a href="qtableitem.html">QTableItem</a> using
336<a href="#item">item</a>(), or as a string with <a href="#text">text</a>() or as a pixmap (if there is
337one) with <a href="#pixmap">pixmap</a>(). A cell's bounding rectangle is given by
338<a href="#cellGeometry">cellGeometry</a>(). Use <a href="#updateCell">updateCell</a>() to repaint a cell, for example to
339clear away a cell's visual representation after it has been
340deleted with <a href="#clearCell">clearCell</a>(). The table can be forced to scroll to
341show a particular cell with <a href="#ensureCellVisible">ensureCellVisible</a>(). The <a href="#isSelected">isSelected</a>()
342function indicates if a cell is selected.
343<p> It is possible to use your own widget as a cell's widget using
344<a href="#setCellWidget">setCellWidget</a>(), but subclassing QTableItem might be a simpler
345approach. The cell's widget (if there is one) can be removed with
346<a href="#clearCellWidget">clearCellWidget</a>().
347<p> <!-- index notes on large tables --><a name="notes-on-large-tables"></a><a name="bigtables"></a>
348<h4> Large tables
349</h4>
350<a name="1-2-1"></a><p> For large, sparse, tables using QTableItems or other widgets is
351inefficient. The solution is to <em>draw</em> the cell as it should
352appear and to create and destroy cell editors on demand.
353<p> This approach requires that you reimplement various functions.
354Reimplement <a href="#paintCell">paintCell</a>() to display your data, and <a href="#createEditor">createEditor</a>()
355and <a href="#setCellContentFromEditor">setCellContentFromEditor</a>() to support in-place editing. It
356is very important to reimplement <a href="#resizeData">resizeData</a>() to have no
357functionality, to prevent QTable from attempting to create a huge
358array. You will also need to reimplement <a href="#item">item</a>(), <a href="#setItem">setItem</a>(),
359<a href="#takeItem">takeItem</a>(), <a href="#clearCell">clearCell</a>(), and <a href="#insertWidget">insertWidget</a>(), <a href="#cellWidget">cellWidget</a>() and
360<a href="#clearCellWidget">clearCellWidget</a>(). In almost every circumstance (for sorting,
361removing and inserting columns and rows, etc.), you also need
362to reimplement <a href="#swapRows">swapRows</a>(), <a href="#swapCells">swapCells</a>() and <a href="#swapColumns">swapColumns</a>(), including
363header handling.
364<p> If you represent active cells with a dictionary of QTableItems and
365QWidgets, i.e. only store references to cells that are actually
366used, many of the functions can be implemented with a single line
367of code. (See the <a href="table-bigtable-main-cpp.html">table/bigtable/main.cpp</a> example.)
368<p> For more information on cells see the <a href="qtableitem.html">QTableItem</a> documenation.
369<p> <a name="selections"></a>
370<h3> Selections
371</h3>
372<a name="1-3"></a><p> QTable's support single selection, multi-selection (multiple
373cells) or no selection. The selection mode is set with
374<a href="#setSelectionMode">setSelectionMode</a>(). Use <a href="#isSelected">isSelected</a>() to determine if a particular
375cell is selected, and <a href="#isRowSelected">isRowSelected</a>() and <a href="#isColumnSelected">isColumnSelected</a>() to
376see if a row or column is selected.
377<p> QTable's support many simultaneous selections. You can
378programmatically select cells with <a href="#addSelection">addSelection</a>(). The number of
379selections is given by <a href="#numSelections">numSelections</a>(). The current selection is
380returned by <a href="#currentSelection">currentSelection</a>(). You can remove a selection with
381<a href="#removeSelection">removeSelection</a>() and remove all selections with
382<a href="#clearSelection">clearSelection</a>(). Selections are <a href="qtableselection.html">QTableSelection</a> objects.
383<p> To easily add a new selection use <a href="#selectCells">selectCells</a>(), <a href="#selectRow">selectRow</a>() or
384<a href="#selectColumn">selectColumn</a>().
385<p> Alternatively, use addSelection() to add new selections using
386QTableSelection objects. The advantage of using QTableSelection
387objects is that you can call <a href="qtableselection.html#expandTo">QTableSelection::expandTo</a>() to resize
388the selection and can query and compare them.
389<p> The number of selections is given by numSelections(). The current
390selection is returned by currentSelection(). You can remove a
391selection with removeSelection() and remove all selections with
392clearSelection().
393<p> <a name="signals"></a>
394<h3> Signals
395</h3>
396<a name="1-4"></a><p> When the user clicks a cell the <a href="#currentChanged">currentChanged</a>() signal is
397emitted. You can also connect to the lower level <a href="#clicked">clicked</a>(),
398<a href="#doubleClicked">doubleClicked</a>() and <a href="#pressed">pressed</a>() signals. If the user changes the
399selection the <a href="#selectionChanged">selectionChanged</a>() signal is emitted; similarly if
400the user changes a cell's value the <a href="#valueChanged">valueChanged</a>() signal is
401emitted. If the user right-clicks (or presses the appropriate
402platform-specific key sequence) the <a href="#contextMenuRequested">contextMenuRequested</a>() signal
403is emitted. If the user drops a drag and drop object the <a href="#dropped">dropped</a>()
404signal is emitted with the drop event.
405<p>See also <a href="advanced.html">Advanced Widgets</a>.
406
407<hr><h2>Member Type Documentation</h2>
408<h3 class=fn><a name="EditMode-enum"></a>QTable::EditMode</h3>
409
410<ul>
411<li><tt>QTable::NotEditing</tt> - No cell is currently being edited.
412<li><tt>QTable::Editing</tt> - A cell is currently being edited. The editor was
413initialised with the cell's contents.
414<li><tt>QTable::Replacing</tt> - A cell is currently being edited. The editor was
415not initialised with the cell's contents.
416</ul>
417<h3 class=fn><a name="FocusStyle-enum"></a>QTable::FocusStyle</h3>
418
419<p> Specifies how the current cell (focus cell) is drawn.
420<ul>
421<li><tt>QTable::FollowStyle</tt> - The current cell is drawn according to the
422current style and the cell's background is also drawn selected, if
423the current cell is within a selection
424<li><tt>QTable::SpreadSheet</tt> - The current cell is drawn as in a spreadsheet.
425This means, it is signified by a black rectangle around the cell,
426and the background of the current cell is always drawn with the
427widget's base color - even when selected.
428</ul><p>
429<h3 class=fn><a name="SelectionMode-enum"></a>QTable::SelectionMode</h3>
430
431<ul>
432<li><tt>QTable::NoSelection</tt> - No cell can be selected by the user.
433<li><tt>QTable::Single</tt> - The user may only select a single range of cells.
434<li><tt>QTable::Multi</tt> - The user may select multiple ranges of cells.
435<li><tt>QTable::SingleRow</tt> - The user may select one row at once.
436<li><tt>QTable::MultiRow</tt> - The user may select multiple rows.
437</ul>
438<hr><h2>Member Function Documentation</h2>
439<h3 class=fn><a name="QTable"></a>QTable::QTable ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
440</h3>
441Creates an empty table object called <em>name</em> as a child of <em>parent</em>.
442<p> Call <a href="#setNumRows">setNumRows</a>() and <a href="#setNumCols">setNumCols</a>() to set the table size before
443populating the table if you're using QTableItems.
444<p> <p>See also <a href="qwidget.html#clearWFlags">QWidget::clearWFlags</a>() and <a href="qt.html#WidgetFlags-enum">Qt::WidgetFlags</a>.
445
446<h3 class=fn><a name="QTable-2"></a>QTable::QTable ( int&nbsp;numRows, int&nbsp;numCols, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
447</h3>
448Constructs an empty table called <em>name</em> with <em>numRows</em> rows and
449<em>numCols</em> columns. The table is a child of <em>parent</em>.
450<p> If you're using <a href="qtableitem.html">QTableItem</a>s to populate the table's cells, you
451can create <a href="qtableitem.html">QTableItem</a>, <a href="qcombotableitem.html">QComboTableItem</a> and <a href="qchecktableitem.html">QCheckTableItem</a> items
452and insert them into the table using <a href="#setItem">setItem</a>(). (See the <a href="qtable.html#notes-on-large-tables">notes on large tables</a> for an alternative to using QTableItems.)
453<p> <p>See also <a href="qwidget.html#clearWFlags">QWidget::clearWFlags</a>() and <a href="qt.html#WidgetFlags-enum">Qt::WidgetFlags</a>.
454
455<h3 class=fn><a name="~QTable"></a>QTable::~QTable ()
456</h3>
457Releases all the resources used by the QTable object,
458including all <a href="qtableitem.html">QTableItem</a>s and their widgets.
459
460<h3 class=fn>void <a name="activateNextCell"></a>QTable::activateNextCell ()<tt> [virtual protected]</tt>
461</h3>
462This function is called to activate the next cell if in-place
463editing was finished by pressing the Enter key.
464<p> The default behaviour is to move from top to bottom, i.e. move to
465the cell beneath the cell being edited. Reimplement this function
466if you want different behaviour, e.g. moving from left to right.
467
468<h3 class=fn>int <a name="addSelection"></a>QTable::addSelection ( const&nbsp;<a href="qtableselection.html">QTableSelection</a>&nbsp;&amp;&nbsp;s )<tt> [virtual]</tt>
469</h3>
470Adds a selection described by <em>s</em> to the table and returns its
471number or -1 if the selection is invalid.
472<p> Remember to call <a href="qtableselection.html#init">QTableSelection::init</a>() and
473<a href="qtableselection.html#expandTo">QTableSelection::expandTo</a>() to make the selection valid (see also
474<a href="qtableselection.html#isActive">QTableSelection::isActive</a>(), or use the
475<a href="qtableselection.html">QTableSelection</a>(int,int,int,int) constructor).
476<p> <p>See also <a href="#numSelections-prop">numSelections</a>, <a href="#removeSelection">removeSelection</a>(), and <a href="#clearSelection">clearSelection</a>().
477
478<h3 class=fn>void <a name="adjustColumn"></a>QTable::adjustColumn ( int&nbsp;col )<tt> [virtual slot]</tt>
479</h3>
480Resizes column <em>col</em> so that the column width is wide enough to
481display the widest item the column contains.
482<p> <p>See also <a href="#adjustRow">adjustRow</a>().
483
484<p>Example: <a href="regexptester-example.html#x2498">regexptester/regexptester.cpp</a>.
485<p>Reimplemented in <a href="qdatatable.html#adjustColumn">QDataTable</a>.
486<h3 class=fn>void <a name="adjustRow"></a>QTable::adjustRow ( int&nbsp;row )<tt> [virtual slot]</tt>
487</h3>
488Resizes row <em>row</em> so that the row height is tall enough to
489display the tallest item the row contains.
490<p> <p>See also <a href="#adjustColumn">adjustColumn</a>().
491
492<h3 class=fn><a href="qwidget.html">QWidget</a>&nbsp;* <a name="beginEdit"></a>QTable::beginEdit ( int&nbsp;row, int&nbsp;col, bool&nbsp;replace )<tt> [virtual protected]</tt>
493</h3>
494This function is called to start in-place editing of the cell at
495<em>row</em>, <em>col</em>. Editing is achieved by creating an editor
496(<a href="#createEditor">createEditor</a>() is called) and setting the cell's editor with
497<a href="#setCellWidget">setCellWidget</a>() to the newly created editor. (After editing is
498complete <a href="#endEdit">endEdit</a>() will be called to replace the cell's content
499with the editor's content.) If <em>replace</em> is TRUE the editor will
500start empty; otherwise it will be initialized with the cell's
501content (if any), i.e. the user will be modifying the original
502cell content.
503<p> <p>See also <a href="#endEdit">endEdit</a>().
504
505<h3 class=fn><a href="qrect.html">QRect</a> <a name="cellGeometry"></a>QTable::cellGeometry ( int&nbsp;row, int&nbsp;col ) const<tt> [virtual]</tt>
506</h3>
507Returns the bounding rectangle of the cell at <em>row</em>, <em>col</em> in
508content coordinates.
509
510<h3 class=fn><a href="qrect.html">QRect</a> <a name="cellRect"></a>QTable::cellRect ( int&nbsp;row, int&nbsp;col ) const<tt> [virtual]</tt>
511</h3>
512Returns the geometry of cell <em>row</em>, <em>col</em> in the cell's
513coordinate system. This is a convenience function useful in
514<a href="#paintCell">paintCell</a>(). It is equivalent to <a href="qrect.html">QRect</a>( <a href="qpoint.html">QPoint</a>(0,0), <a href="#cellGeometry">cellGeometry</a>(
515row, col).<a href="qwidget.html#size">size</a>() );
516<p> <p>See also <a href="#cellGeometry">cellGeometry</a>().
517
518<p>Example: <a href="tutorial2-08.html#x2610">chart/setdataform.cpp</a>.
519<h3 class=fn><a href="qwidget.html">QWidget</a>&nbsp;* <a name="cellWidget"></a>QTable::cellWidget ( int&nbsp;row, int&nbsp;col ) const<tt> [virtual]</tt>
520</h3>
521Returns the widget that has been set for the cell at <em>row</em>, <em>col</em>, or 0 if no widget has been set.
522<p> If you don't use <a href="qtableitem.html">QTableItem</a>s you may need to reimplement this
523function: see the <a href="qtable.html#notes-on-large-tables">notes on large tables</a>.
524<p> <p>See also <a href="#clearCellWidget">clearCellWidget</a>() and <a href="#setCellWidget">setCellWidget</a>().
525
526<p>Example: <a href="tutorial2-08.html#x2611">chart/setdataform.cpp</a>.
527<h3 class=fn>void <a name="clearCell"></a>QTable::clearCell ( int&nbsp;row, int&nbsp;col )<tt> [virtual]</tt>
528</h3>
529Removes the <a href="qtableitem.html">QTableItem</a> at <em>row</em>, <em>col</em>.
530<p> If you don't use <a href="qtableitem.html">QTableItem</a>s you may need to reimplement this
531function: see the <a href="qtable.html#notes-on-large-tables">notes on large tables</a>.
532
533<h3 class=fn>void <a name="clearCellWidget"></a>QTable::clearCellWidget ( int&nbsp;row, int&nbsp;col )<tt> [virtual]</tt>
534</h3>
535Removes the widget (if there is one) set for the cell at <em>row</em>,
536<em>col</em>.
537<p> If you don't use <a href="qtableitem.html">QTableItem</a>s you may need to reimplement this
538function: see the <a href="qtable.html#notes-on-large-tables">notes on large tables</a>.
539<p> This function deletes the widget at <em>row</em>, <em>col</em>. Note that the
540widget is not deleted immediately; instead <a href="qobject.html#deleteLater">QObject::deleteLater</a>()
541is called on the widget to avoid problems with timing issues.
542<p> <p>See also <a href="#cellWidget">cellWidget</a>() and <a href="#setCellWidget">setCellWidget</a>().
543
544<h3 class=fn>void <a name="clearSelection"></a>QTable::clearSelection ( bool&nbsp;repaint = TRUE )<tt> [slot]</tt>
545</h3>
546Clears all selections and repaints the appropriate regions if <em>repaint</em> is TRUE.
547<p> <p>See also <a href="#removeSelection">removeSelection</a>().
548
549<h3 class=fn>void <a name="clicked"></a>QTable::clicked ( int&nbsp;row, int&nbsp;col, int&nbsp;button, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;mousePos )<tt> [signal]</tt>
550</h3>
551
552<p> This signal is emitted when mouse button <em>button</em> is clicked. The
553cell where the event took place is at <em>row</em>, <em>col</em>, and the
554mouse's position is in <em>mousePos</em>.
555<p> <p>See also <a href="qt.html#ButtonState-enum">Qt::ButtonState</a>.
556
557<p>Example: <a href="tutorial2-08.html#x2612">chart/setdataform.cpp</a>.
558<h3 class=fn>int <a name="columnAt"></a>QTable::columnAt ( int&nbsp;x ) const<tt> [virtual]</tt>
559</h3>
560Returns the number of the column at position <em>x</em>. <em>x</em> must be
561given in content coordinates.
562<p> <p>See also <a href="#columnPos">columnPos</a>() and <a href="#rowAt">rowAt</a>().
563
564<h3 class=fn>void <a name="columnClicked"></a>QTable::columnClicked ( int&nbsp;col )<tt> [virtual protected slot]</tt>
565</h3>
566This function is called when the column <em>col</em> has been clicked.
567The default implementation sorts this column if <a href="#sorting">sorting</a>() is TRUE.
568
569<h3 class=fn>void <a name="columnIndexChanged"></a>QTable::columnIndexChanged ( int&nbsp;section, int&nbsp;fromIndex, int&nbsp;toIndex )<tt> [virtual protected slot]</tt>
570</h3>
571This function is called when column order is to be changed, i.e.
572when the user moved the column header <em>section</em> from <em>fromIndex</em>
573to <em>toIndex</em>.
574<p> If you want to change the column order programmatically, call
575<a href="#swapRows">swapRows</a>() or <a href="#swapColumns">swapColumns</a>();
576<p> <p>See also <a href="qheader.html#indexChange">QHeader::indexChange</a>() and <a href="#rowIndexChanged">rowIndexChanged</a>().
577
578<h3 class=fn>bool <a name="columnMovingEnabled"></a>QTable::columnMovingEnabled () const
579</h3><p>Returns TRUE if columns can be moved by the user; otherwise returns FALSE.
580See the <a href="qtable.html#columnMovingEnabled-prop">"columnMovingEnabled"</a> property for details.
581<h3 class=fn>int <a name="columnPos"></a>QTable::columnPos ( int&nbsp;col ) const<tt> [virtual]</tt>
582</h3>
583Returns the x-coordinate of the column <em>col</em> in content
584coordinates.
585<p> <p>See also <a href="#columnAt">columnAt</a>() and <a href="#rowPos">rowPos</a>().
586
587<h3 class=fn>int <a name="columnWidth"></a>QTable::columnWidth ( int&nbsp;col ) const<tt> [virtual]</tt>
588</h3>
589Returns the width of column <em>col</em>.
590<p> <p>See also <a href="#setColumnWidth">setColumnWidth</a>() and <a href="#rowHeight">rowHeight</a>().
591
592<h3 class=fn>void <a name="columnWidthChanged"></a>QTable::columnWidthChanged ( int&nbsp;col )<tt> [virtual protected slot]</tt>
593</h3>
594This function should be called whenever the column width of <em>col</em>
595has been changed. It updates the geometry of any affected columns
596and repaints the table to reflect the changes it has made.
597
598<h3 class=fn>void <a name="contentsDragEnterEvent"></a>QTable::contentsDragEnterEvent ( <a href="qdragenterevent.html">QDragEnterEvent</a>&nbsp;*&nbsp;e )<tt> [virtual protected]</tt>
599</h3>
600This event handler is called whenever a QTable object receives a
601<a href="qdragenterevent.html">QDragEnterEvent</a> <em>e</em>, i.e. when the user pressed the mouse
602button to drag something.
603<p> The focus is moved to the cell where the <a href="qdragenterevent.html">QDragEnterEvent</a> occurred.
604
605<p>Reimplemented from <a href="qscrollview.html#contentsDragEnterEvent">QScrollView</a>.
606<h3 class=fn>void <a name="contentsDragLeaveEvent"></a>QTable::contentsDragLeaveEvent ( <a href="qdragleaveevent.html">QDragLeaveEvent</a>&nbsp;*&nbsp;e )<tt> [virtual protected]</tt>
607</h3>
608This event handler is called when a drag activity leaves <em>this</em>
609QTable object with event <em>e</em>.
610
611<p>Reimplemented from <a href="qscrollview.html#contentsDragLeaveEvent">QScrollView</a>.
612<h3 class=fn>void <a name="contentsDragMoveEvent"></a>QTable::contentsDragMoveEvent ( <a href="qdragmoveevent.html">QDragMoveEvent</a>&nbsp;*&nbsp;e )<tt> [virtual protected]</tt>
613</h3>
614This event handler is called whenever a QTable object receives a
615<a href="qdragmoveevent.html">QDragMoveEvent</a> <em>e</em>, i.e. when the user actually drags the
616mouse.
617<p> The focus is moved to the cell where the <a href="qdragmoveevent.html">QDragMoveEvent</a> occurred.
618
619<p>Reimplemented from <a href="qscrollview.html#contentsDragMoveEvent">QScrollView</a>.
620<h3 class=fn>void <a name="contentsDropEvent"></a>QTable::contentsDropEvent ( <a href="qdropevent.html">QDropEvent</a>&nbsp;*&nbsp;e )<tt> [virtual protected]</tt>
621</h3>
622This event handler is called when the user ends a drag and drop by
623dropping something onto <em>this</em> QTable and thus triggers the drop
624event, <em>e</em>.
625
626<p>Reimplemented from <a href="qscrollview.html#contentsDropEvent">QScrollView</a>.
627<h3 class=fn>void <a name="contextMenuRequested"></a>QTable::contextMenuRequested ( int&nbsp;row, int&nbsp;col, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;pos )<tt> [signal]</tt>
628</h3>
629
630<p> This signal is emitted when the user invokes a context menu with
631the right mouse button (or with a system-specific keypress). The
632cell where the event took place is at <em>row</em>, <em>col</em>. <em>pos</em> is
633the position where the context menu will appear in the global
634coordinate system. This signal is always emitted, even if the
635contents of the cell are disabled.
636
637<h3 class=fn><a href="qwidget.html">QWidget</a>&nbsp;* <a name="createEditor"></a>QTable::createEditor ( int&nbsp;row, int&nbsp;col, bool&nbsp;initFromCell ) const<tt> [virtual protected]</tt>
638</h3>
639This function returns the widget which should be used as an editor
640for the contents of the cell at <em>row</em>, <em>col</em>.
641<p> If <em>initFromCell</em> is TRUE, the editor is used to edit the current
642contents of the cell (so the editor widget should be initialized
643with this content). If <em>initFromCell</em> is FALSE, the content of
644the cell is replaced with the new content which the user entered
645into the widget created by this function.
646<p> The default functionality is as follows: if <em>initFromCell</em> is
647TRUE or the cell has a <a href="qtableitem.html">QTableItem</a> and the table item's
648<a href="qtableitem.html#isReplaceable">QTableItem::isReplaceable</a>() is FALSE then the cell is asked to
649create an appropriate editor (using <a href="qtableitem.html#createEditor">QTableItem::createEditor</a>()).
650Otherwise a <a href="qlineedit.html">QLineEdit</a> is used as the editor.
651<p> If you want to create your own editor for certain cells, implement
652a custom QTableItem subclass and reimplement
653QTableItem::createEditor().
654<p> If you are not using <a href="qtableitem.html">QTableItem</a>s and you don't want to use a
655QLineEdit as the default editor, subclass QTable and reimplement
656this function with code like this:
657<pre>
658 <a href="qtableitem.html">QTableItem</a> *i = <a href="#item">item</a>( row, col );
659 if ( initFromCell || ( i &amp;&amp; !i-&gt;<a href="qtableitem.html#isReplaceable">isReplaceable</a>() ) )
660 // If we had a QTableItem ask the base class to create the editor
661 return QTable::createEditor( row, col, initFromCell );
662 else
663 return ...(create your own editor)
664 </pre>
665
666Ownership of the editor widget is transferred to the caller.
667<p> If you reimplement this function return 0 for read-only cells. You
668will need to reimplement <a href="#setCellContentFromEditor">setCellContentFromEditor</a>() to retrieve
669the data the user entered.
670<p> <p>See also <a href="qtableitem.html#createEditor">QTableItem::createEditor</a>().
671
672<h3 class=fn>int <a name="currEditCol"></a>QTable::currEditCol () const<tt> [protected]</tt>
673</h3>
674Returns the current edited column
675
676<h3 class=fn>int <a name="currEditRow"></a>QTable::currEditRow () const<tt> [protected]</tt>
677</h3>
678Returns the current edited row
679
680<h3 class=fn>void <a name="currentChanged"></a>QTable::currentChanged ( int&nbsp;row, int&nbsp;col )<tt> [signal]</tt>
681</h3>
682
683<p> This signal is emitted when the current cell has changed to <em>row</em>, <em>col</em>.
684
685<p>Example: <a href="tutorial2-08.html#x2613">chart/setdataform.cpp</a>.
686<h3 class=fn>int <a name="currentColumn"></a>QTable::currentColumn () const
687</h3>
688
689<p> Returns the current column.
690<p> <p>See also <a href="#currentRow">currentRow</a>().
691
692<p>Example: <a href="tutorial2-08.html#x2614">chart/setdataform.cpp</a>.
693<h3 class=fn>int <a name="currentRow"></a>QTable::currentRow () const
694</h3>
695
696<p> Returns the current row.
697<p> <p>See also <a href="#currentColumn">currentColumn</a>().
698
699<p>Example: <a href="tutorial2-08.html#x2615">chart/setdataform.cpp</a>.
700<h3 class=fn>int <a name="currentSelection"></a>QTable::currentSelection () const<tt> [virtual]</tt>
701</h3>
702Returns the number of the current selection or -1 if there is no
703current selection.
704<p> <p>See also <a href="#numSelections-prop">numSelections</a>.
705
706<h3 class=fn>void <a name="doubleClicked"></a>QTable::doubleClicked ( int&nbsp;row, int&nbsp;col, int&nbsp;button, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;mousePos )<tt> [signal]</tt>
707</h3>
708
709<p> This signal is emitted when mouse button <em>button</em> is
710double-clicked. The cell where the event took place is at <em>row</em>,
711<em>col</em>, and the mouse's position is in <em>mousePos</em>.
712<p> <p>See also <a href="qt.html#ButtonState-enum">Qt::ButtonState</a>.
713
714<h3 class=fn>bool <a name="dragEnabled"></a>QTable::dragEnabled () const<tt> [slot]</tt>
715</h3>
716If this function returns TRUE, the table supports dragging.
717<p> <p>See also <a href="#setDragEnabled">setDragEnabled</a>().
718
719<h3 class=fn><a href="qdragobject.html">QDragObject</a>&nbsp;* <a name="dragObject"></a>QTable::dragObject ()<tt> [virtual protected]</tt>
720</h3>
721If the user presses the mouse on a selected cell, starts moving
722(i.e. dragging), and <a href="#dragEnabled">dragEnabled</a>() is TRUE, this function is
723called to obtain a drag object. A drag using this object begins
724immediately unless <a href="#dragObject">dragObject</a>() returns 0.
725<p> By default this function returns 0. You might reimplement it and
726create a <a href="qdragobject.html">QDragObject</a> depending on the selected items.
727<p> <p>See also <a href="#dropped">dropped</a>().
728
729<h3 class=fn>void <a name="drawContents"></a>QTable::drawContents ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, int&nbsp;cx, int&nbsp;cy, int&nbsp;cw, int&nbsp;ch )<tt> [virtual protected]</tt>
730</h3>
731Draws the table contents on the painter <em>p</em>. This function is
732optimized so that it only draws the cells inside the <em>cw</em> pixels
733wide and <em>ch</em> pixels high clipping rectangle at position <em>cx</em>,
734<em>cy</em>.
735<p> Additionally, <a href="#drawContents">drawContents</a>() highlights the current cell.
736
737<p>Reimplemented from <a href="qscrollview.html#drawContents">QScrollView</a>.
738<h3 class=fn>void <a name="dropped"></a>QTable::dropped ( <a href="qdropevent.html">QDropEvent</a>&nbsp;*&nbsp;e )<tt> [signal]</tt>
739</h3>
740
741<p> This signal is emitted when a drop event occurred on the table.
742<p> <em>e</em> contains information about the drop.
743
744<h3 class=fn>void <a name="editCell"></a>QTable::editCell ( int&nbsp;row, int&nbsp;col, bool&nbsp;replace = FALSE )<tt> [virtual slot]</tt>
745</h3>
746Starts editing the cell at <em>row</em>, <em>col</em>.
747<p> If <em>replace</em> is TRUE the content of this cell will be replaced by
748the content of the editor when editing is finished, i.e. the user
749will be entering new data; otherwise the current content of the
750cell (if any) will be modified in the editor.
751<p> <p>See also <a href="#beginEdit">beginEdit</a>().
752
753<h3 class=fn><a href="qtable.html#EditMode-enum">EditMode</a> <a name="editMode"></a>QTable::editMode () const<tt> [protected]</tt>
754</h3>
755Returns the current edit mode
756<p> <p>See also <a href="#EditMode-enum">QTable::EditMode</a>.
757
758<h3 class=fn>void <a name="endEdit"></a>QTable::endEdit ( int&nbsp;row, int&nbsp;col, bool&nbsp;accept, bool&nbsp;replace )<tt> [virtual protected]</tt>
759</h3>
760This function is called when in-place editing of the cell at <em>row</em>, <em>col</em> is requested to stop.
761<p> If the cell is not being edited or <em>accept</em> is FALSE the function
762returns and the cell's contents are left unchanged.
763<p> If <em>accept</em> is TRUE the content of the editor must be transferred
764to the relevant cell. If <em>replace</em> is TRUE the current content of
765this cell should be replaced by the content of the editor (this
766means removing the current <a href="qtableitem.html">QTableItem</a> of the cell and creating a
767new one for the cell). Otherwise (if possible) the content of the
768editor should just be set to the existing QTableItem of this cell.
769<p> <a href="#setCellContentFromEditor">setCellContentFromEditor</a>() is called to replace the contents of
770the cell with the contents of the cell's editor.
771<p> Finally <a href="#clearCellWidget">clearCellWidget</a>() is called to remove the editor widget.
772<p> <p>See also <a href="#setCellContentFromEditor">setCellContentFromEditor</a>() and <a href="#beginEdit">beginEdit</a>().
773
774<h3 class=fn>void <a name="ensureCellVisible"></a>QTable::ensureCellVisible ( int&nbsp;row, int&nbsp;col )
775</h3>
776Scrolls the table until the cell at <em>row</em>, <em>col</em> becomes
777visible.
778
779<h3 class=fn><a href="qtable.html#FocusStyle-enum">FocusStyle</a> <a name="focusStyle"></a>QTable::focusStyle () const
780</h3><p>Returns how the current (focus) cell is drawn.
781See the <a href="qtable.html#focusStyle-prop">"focusStyle"</a> property for details.
782<h3 class=fn>void <a name="hideColumn"></a>QTable::hideColumn ( int&nbsp;col )<tt> [virtual slot]</tt>
783</h3>
784Hides column <em>col</em>.
785<p> <p>See also <a href="#showColumn">showColumn</a>() and <a href="#hideRow">hideRow</a>().
786
787<h3 class=fn>void <a name="hideRow"></a>QTable::hideRow ( int&nbsp;row )<tt> [virtual slot]</tt>
788</h3>
789Hides row <em>row</em>.
790<p> <p>See also <a href="#showRow">showRow</a>() and <a href="#hideColumn">hideColumn</a>().
791
792<h3 class=fn><a href="qheader.html">QHeader</a>&nbsp;* <a name="horizontalHeader"></a>QTable::horizontalHeader () const
793</h3>
794Returns the table's top <a href="qheader.html">QHeader</a>.
795<p> This header contains the column labels.
796<p> To modify a column label use <a href="qheader.html#setLabel">QHeader::setLabel</a>(), e.g.
797
798
799<pre> <a href="#horizontalHeader">horizontalHeader</a>()-&gt;setLabel( 0, tr( "File" ) );
800</pre>
801<p> <p>See also <a href="#verticalHeader">verticalHeader</a>(), <a href="#setTopMargin">setTopMargin</a>(), and <a href="qheader.html">QHeader</a>.
802
803<p>Examples: <a href="tutorial2-08.html#x2616">chart/setdataform.cpp</a>, <a href="helpsystem-example.html#x2690">helpsystem/mainwindow.cpp</a>, <a href="regexptester-example.html#x2499">regexptester/regexptester.cpp</a>, and <a href="small-table-example-example.html#x2800">table/small-table-demo/main.cpp</a>.
804<h3 class=fn>int <a name="indexOf"></a>QTable::indexOf ( int&nbsp;row, int&nbsp;col ) const<tt> [protected]</tt>
805</h3>
806Returns a single integer which identifies a particular <em>row</em> and <em>col</em> by mapping the 2D table to a 1D array.
807<p> This is useful, for example, if you have a sparse table and want to
808use a <a href="qintdict.html">QIntDict</a> to map integers to the cells that are used.
809
810<h3 class=fn>void <a name="insertColumns"></a>QTable::insertColumns ( int&nbsp;col, int&nbsp;count = 1 )<tt> [virtual slot]</tt>
811</h3>
812Inserts <em>count</em> empty columns at column <em>col</em>. Also clears the <a href="#selection">selection</a>(s).
813<p> <p>See also <a href="#insertRows">insertRows</a>() and <a href="#removeColumn">removeColumn</a>().
814
815<h3 class=fn>void <a name="insertRows"></a>QTable::insertRows ( int&nbsp;row, int&nbsp;count = 1 )<tt> [virtual slot]</tt>
816</h3>
817Inserts <em>count</em> empty rows at row <em>row</em>. Also clears the <a href="#selection">selection</a>(s).
818<p> <p>See also <a href="#insertColumns">insertColumns</a>() and <a href="#removeRow">removeRow</a>().
819
820<h3 class=fn>void <a name="insertWidget"></a>QTable::insertWidget ( int&nbsp;row, int&nbsp;col, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w )<tt> [virtual protected]</tt>
821</h3>
822Inserts widget <em>w</em> at <em>row</em>, <em>col</em> into the internal
823data structure. See the documentation of <a href="#setCellWidget">setCellWidget</a>() for
824further details.
825<p> If you don't use <a href="qtableitem.html">QTableItem</a>s you may need to reimplement this
826function: see the <a href="qtable.html#notes-on-large-tables">notes on large tables</a>.
827
828<h3 class=fn>bool <a name="isColumnHidden"></a>QTable::isColumnHidden ( int&nbsp;col ) const<tt> [slot]</tt>
829</h3>
830Returns TRUE if column <em>col</em> is hidden; otherwise returns
831FALSE.
832<p> <p>See also <a href="#hideColumn">hideColumn</a>() and <a href="#isRowHidden">isRowHidden</a>().
833
834<h3 class=fn>bool <a name="isColumnReadOnly"></a>QTable::isColumnReadOnly ( int&nbsp;col ) const
835</h3>
836Returns TRUE if column <em>col</em> is read-only; otherwise returns
837FALSE.
838<p> Whether a cell in this column is editable or read-only depends on
839the cell's EditType, and this setting: see <a href="qtableitem.html#wheneditable">QTableItem::EditType</a>.
840<p> <p>See also <a href="#setColumnReadOnly">setColumnReadOnly</a>() and <a href="#isRowReadOnly">isRowReadOnly</a>().
841
842<h3 class=fn>bool <a name="isColumnSelected"></a>QTable::isColumnSelected ( int&nbsp;col, bool&nbsp;full = FALSE ) const
843</h3>
844Returns TRUE if column <em>col</em> is selected; otherwise returns FALSE.
845<p> If <em>full</em> is FALSE (the default), 'column is selected' means that
846at least one cell in the column is selected. If <em>full</em> is TRUE,
847then 'column is selected' means every cell in the column is
848selected.
849<p> <p>See also <a href="#isRowSelected">isRowSelected</a>() and <a href="#isSelected">isSelected</a>().
850
851<h3 class=fn>bool <a name="isColumnStretchable"></a>QTable::isColumnStretchable ( int&nbsp;col ) const<tt> [slot]</tt>
852</h3>
853Returns TRUE if column <em>col</em> is stretchable; otherwise returns
854FALSE.
855<p> <p>See also <a href="#setColumnStretchable">setColumnStretchable</a>() and <a href="#isRowStretchable">isRowStretchable</a>().
856
857<h3 class=fn>bool <a name="isEditing"></a>QTable::isEditing () const<tt> [protected]</tt>
858</h3>
859Returns TRUE if the <a href="#EditMode-enum">EditMode</a> is <a href="#EditMode-enum">Editing</a> or <a href="#EditMode-enum">Replacing</a>;
860otherwise (i.e. the <a href="#EditMode-enum">EditMode</a> is <a href="#EditMode-enum">NotEditing</a>) returns FALSE.
861<p> <p>See also <a href="#EditMode-enum">QTable::EditMode</a>.
862
863<h3 class=fn>bool <a name="isReadOnly"></a>QTable::isReadOnly () const
864</h3><p>Returns TRUE if the table is read-only; otherwise returns FALSE.
865See the <a href="qtable.html#readOnly-prop">"readOnly"</a> property for details.
866<h3 class=fn>bool <a name="isRowHidden"></a>QTable::isRowHidden ( int&nbsp;row ) const<tt> [slot]</tt>
867</h3>
868Returns TRUE if row <em>row</em> is hidden; otherwise returns
869FALSE.
870<p> <p>See also <a href="#hideRow">hideRow</a>() and <a href="#isColumnHidden">isColumnHidden</a>().
871
872<h3 class=fn>bool <a name="isRowReadOnly"></a>QTable::isRowReadOnly ( int&nbsp;row ) const
873</h3>
874Returns TRUE if row <em>row</em> is read-only; otherwise returns FALSE.
875<p> Whether a cell in this row is editable or read-only depends on the
876cell's <a href="qtableitem.html#EditType-enum">EditType</a>, and this
877setting: see <a href="qtableitem.html#wheneditable">QTableItem::EditType</a>.
878<p> <p>See also <a href="#setRowReadOnly">setRowReadOnly</a>() and <a href="#isColumnReadOnly">isColumnReadOnly</a>().
879
880<h3 class=fn>bool <a name="isRowSelected"></a>QTable::isRowSelected ( int&nbsp;row, bool&nbsp;full = FALSE ) const
881</h3>
882Returns TRUE if row <em>row</em> is selected; otherwise returns FALSE.
883<p> If <em>full</em> is FALSE (the default), 'row is selected' means that at
884least one cell in the row is selected. If <em>full</em> is TRUE, then 'row
885is selected' means every cell in the row is selected.
886<p> <p>See also <a href="#isColumnSelected">isColumnSelected</a>() and <a href="#isSelected">isSelected</a>().
887
888<h3 class=fn>bool <a name="isRowStretchable"></a>QTable::isRowStretchable ( int&nbsp;row ) const<tt> [slot]</tt>
889</h3>
890Returns TRUE if row <em>row</em> is stretchable; otherwise returns
891FALSE.
892<p> <p>See also <a href="#setRowStretchable">setRowStretchable</a>() and <a href="#isColumnStretchable">isColumnStretchable</a>().
893
894<h3 class=fn>bool <a name="isSelected"></a>QTable::isSelected ( int&nbsp;row, int&nbsp;col ) const
895</h3>
896Returns TRUE if the cell at <em>row</em>, <em>col</em> is selected; otherwise
897returns FALSE.
898<p> <p>See also <a href="#isRowSelected">isRowSelected</a>() and <a href="#isColumnSelected">isColumnSelected</a>().
899
900<h3 class=fn><a href="qtableitem.html">QTableItem</a>&nbsp;* <a name="item"></a>QTable::item ( int&nbsp;row, int&nbsp;col ) const<tt> [virtual]</tt>
901</h3>
902Returns the <a href="qtableitem.html">QTableItem</a> representing the contents of the cell at <em>row</em>, <em>col</em>.
903<p> If <em>row</em> or <em>col</em> are out of range or no content has been set
904for this cell, <a href="#item">item</a>() returns 0.
905<p> If you don't use <a href="qtableitem.html">QTableItem</a>s you may need to reimplement this
906function: see the <a href="qtable.html#notes-on-large-tables">notes on large tables</a>.
907<p> <p>See also <a href="#setItem">setItem</a>().
908
909<p>Example: <a href="regexptester-example.html#x2500">regexptester/regexptester.cpp</a>.
910<h3 class=fn>int <a name="numCols"></a>QTable::numCols () const<tt> [virtual]</tt>
911</h3><p>Returns the number of columns in the table.
912See the <a href="qtable.html#numCols-prop">"numCols"</a> property for details.
913<p>Reimplemented in <a href="qdatatable.html#numCols">QDataTable</a>.
914<h3 class=fn>int <a name="numRows"></a>QTable::numRows () const<tt> [virtual]</tt>
915</h3><p>Returns the number of rows in the table.
916See the <a href="qtable.html#numRows-prop">"numRows"</a> property for details.
917<p>Reimplemented in <a href="qdatatable.html#numRows">QDataTable</a>.
918<h3 class=fn>int <a name="numSelections"></a>QTable::numSelections () const
919</h3><p>Returns the number of selections.
920See the <a href="qtable.html#numSelections-prop">"numSelections"</a> property for details.
921<h3 class=fn>void <a name="paintCell"></a>QTable::paintCell ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, int&nbsp;row, int&nbsp;col, const&nbsp;<a href="qrect.html">QRect</a>&nbsp;&amp;&nbsp;cr, bool&nbsp;selected, const&nbsp;<a href="qcolorgroup.html">QColorGroup</a>&nbsp;&amp;&nbsp;cg )<tt> [virtual]</tt>
922</h3>
923Paints the cell at <em>row</em>, <em>col</em> on the painter <em>p</em>. The painter
924has already been translated to the cell's origin. <em>cr</em> describes
925the cell coordinates in the content coordinate system.
926<p> If <em>selected</em> is TRUE the cell is highlighted.
927<p> <em>cg</em> is the colorgroup which should be used to draw the cell
928content.
929<p> If you want to draw custom cell content, for example right-aligned
930text, you must either reimplement <a href="#paintCell">paintCell</a>(), or subclass
931<a href="qtableitem.html">QTableItem</a> and reimplement <a href="qtableitem.html#paint">QTableItem::paint</a>() to do the custom
932drawing.
933<p> If you're using a QTableItem subclass, for example, to store a
934data structure, then reimplementing QTableItem::paint() may be the
935best approach. For data you want to draw immediately, e.g. data
936retrieved from a database, it is probably best to reimplement
937paintCell(). Note that if you reimplement paintCell(), i.e. don't
938use <a href="qtableitem.html">QTableItem</a>s, you must reimplement other functions: see the
939<a href="qtable.html#notes-on-large-tables">notes on large tables</a>.
940<p> Note that the painter is not clipped by default in order to get
941maximum efficiency. If you want clipping, use code like this:
942<p> <pre>
943 p-&gt;setClipRect( <a href="#cellRect">cellRect</a>(row, col), QPainter::CoordPainter );
944 //... your drawing code
945 p-&gt;setClipping( FALSE );
946 </pre>
947
948
949<h3 class=fn>void <a name="paintCell-2"></a>QTable::paintCell ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, int&nbsp;row, int&nbsp;col, const&nbsp;<a href="qrect.html">QRect</a>&nbsp;&amp;&nbsp;cr, bool&nbsp;selected )<tt> [virtual]</tt>
950</h3>
951This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
952<p> Use the other <a href="#paintCell">paintCell</a>() function. This function is only included
953for backwards compatibilty.
954
955<h3 class=fn>void <a name="paintEmptyArea"></a>QTable::paintEmptyArea ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, int&nbsp;cx, int&nbsp;cy, int&nbsp;cw, int&nbsp;ch )<tt> [virtual protected]</tt>
956</h3>
957This function fills the <em>cw</em> pixels wide and <em>ch</em> pixels high
958rectangle starting at position <em>cx</em>, <em>cy</em> with the background
959color using the painter <em>p</em>.
960<p> <a href="#paintEmptyArea">paintEmptyArea</a>() is invoked by <a href="#drawContents">drawContents</a>() to erase or fill
961unused areas.
962
963<h3 class=fn>void <a name="paintFocus"></a>QTable::paintFocus ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, const&nbsp;<a href="qrect.html">QRect</a>&nbsp;&amp;&nbsp;cr )<tt> [virtual]</tt>
964</h3>
965Draws the focus rectangle of the current cell (see <a href="#currentRow">currentRow</a>(),
966<a href="#currentColumn">currentColumn</a>()).
967<p> The painter <em>p</em> is already translated to the cell's origin, while
968<em>cr</em> specifies the cell's geometry in content coordinates.
969
970<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="pixmap"></a>QTable::pixmap ( int&nbsp;row, int&nbsp;col ) const<tt> [virtual]</tt>
971</h3>
972Returns the pixmap set for the cell at <em>row</em>, <em>col</em>, or a
973null-pixmap if the cell contains no pixmap.
974<p> <p>See also <a href="#setPixmap">setPixmap</a>().
975
976<p>Example: <a href="tutorial2-08.html#x2617">chart/setdataform.cpp</a>.
977<h3 class=fn>void <a name="pressed"></a>QTable::pressed ( int&nbsp;row, int&nbsp;col, int&nbsp;button, const&nbsp;<a href="qpoint.html">QPoint</a>&nbsp;&amp;&nbsp;mousePos )<tt> [signal]</tt>
978</h3>
979
980<p> This signal is emitted when mouse button <em>button</em> is pressed. The
981cell where the event took place is at <em>row</em>, <em>col</em>, and the
982mouse's position is in <em>mousePos</em>.
983<p> <p>See also <a href="qt.html#ButtonState-enum">Qt::ButtonState</a>.
984
985<h3 class=fn>void <a name="removeColumn"></a>QTable::removeColumn ( int&nbsp;col )<tt> [virtual slot]</tt>
986</h3>
987Removes column <em>col</em>, and deletes all its cells including any
988table items and widgets the cells may contain. Also clears the
989<a href="#selection">selection</a>(s).
990<p> <p>See also <a href="#removeColumns">removeColumns</a>(), <a href="#hideColumn">hideColumn</a>(), <a href="#insertColumns">insertColumns</a>(), and <a href="#removeRow">removeRow</a>().
991
992<h3 class=fn>void <a name="removeColumns"></a>QTable::removeColumns ( const&nbsp;<a href="qmemarray.html">QMemArray</a>&lt;int&gt;&nbsp;&amp;&nbsp;cols )<tt> [virtual slot]</tt>
993</h3>
994Removes the columns listed in the array <em>cols</em>, and deletes all
995their cells including any table items and widgets the cells may
996contain.
997<p> The array passed in must only contain valid columns (in the range
998from 0 to <a href="#numCols">numCols</a>() - 1) with no duplicates, and must be sorted in
999ascending order. Also clears the <a href="#selection">selection</a>(s).
1000<p> <p>See also <a href="#removeColumn">removeColumn</a>(), <a href="#insertColumns">insertColumns</a>(), and <a href="#removeRows">removeRows</a>().
1001
1002<h3 class=fn>void <a name="removeRow"></a>QTable::removeRow ( int&nbsp;row )<tt> [virtual slot]</tt>
1003</h3>
1004Removes row <em>row</em>, and deletes all its cells including any table
1005items and widgets the cells may contain. Also clears the <a href="#selection">selection</a>(s).
1006<p> <p>See also <a href="#hideRow">hideRow</a>(), <a href="#insertRows">insertRows</a>(), <a href="#removeColumn">removeColumn</a>(), and <a href="#removeRows">removeRows</a>().
1007
1008<h3 class=fn>void <a name="removeRows"></a>QTable::removeRows ( const&nbsp;<a href="qmemarray.html">QMemArray</a>&lt;int&gt;&nbsp;&amp;&nbsp;rows )<tt> [virtual slot]</tt>
1009</h3>
1010Removes the rows listed in the array <em>rows</em>, and deletes all their
1011cells including any table items and widgets the cells may contain.
1012<p> The array passed in must only contain valid rows (in the range
1013from 0 to <a href="#numRows">numRows</a>() - 1) with no duplicates, and must be sorted in
1014ascending order. Also clears the <a href="#selection">selection</a>(s).
1015<p> <p>See also <a href="#removeRow">removeRow</a>(), <a href="#insertRows">insertRows</a>(), and <a href="#removeColumns">removeColumns</a>().
1016
1017<h3 class=fn>void <a name="removeSelection"></a>QTable::removeSelection ( const&nbsp;<a href="qtableselection.html">QTableSelection</a>&nbsp;&amp;&nbsp;s )<tt> [virtual]</tt>
1018</h3>
1019If the table has a selection, <em>s</em>, this selection is removed from
1020the table.
1021<p> <p>See also <a href="#addSelection">addSelection</a>() and <a href="#numSelections-prop">numSelections</a>.
1022
1023<h3 class=fn>void <a name="removeSelection-2"></a>QTable::removeSelection ( int&nbsp;num )<tt> [virtual]</tt>
1024</h3>
1025This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
1026<p> Removes selection number <em>num</em> from the table.
1027<p> <p>See also <a href="#numSelections-prop">numSelections</a>, <a href="#addSelection">addSelection</a>(), and <a href="#clearSelection">clearSelection</a>().
1028
1029<h3 class=fn>void <a name="repaintSelections"></a>QTable::repaintSelections ()
1030</h3>
1031Repaints all selections
1032
1033<h3 class=fn>void <a name="resizeData"></a>QTable::resizeData ( int&nbsp;len )<tt> [virtual protected]</tt>
1034</h3>
1035This is called when QTable's internal array needs to be resized to
1036<em>len</em> elements.
1037<p> If you don't use QTableItems you should reimplement this as an
1038empty method to avoid wasting memory. See the <a href="qtable.html#notes-on-large-tables">notes on large tables</a> for further details.
1039
1040<h3 class=fn>int <a name="rowAt"></a>QTable::rowAt ( int&nbsp;y ) const<tt> [virtual]</tt>
1041</h3>
1042Returns the number of the row at position <em>y</em>. <em>y</em> must be given
1043in content coordinates.
1044<p> <p>See also <a href="#rowPos">rowPos</a>() and <a href="#columnAt">columnAt</a>().
1045
1046<h3 class=fn>int <a name="rowHeight"></a>QTable::rowHeight ( int&nbsp;row ) const<tt> [virtual]</tt>
1047</h3>
1048Returns the height of row <em>row</em>.
1049<p> <p>See also <a href="#setRowHeight">setRowHeight</a>() and <a href="#columnWidth">columnWidth</a>().
1050
1051<p>Example: <a href="small-table-example-example.html#x2801">table/small-table-demo/main.cpp</a>.
1052<h3 class=fn>void <a name="rowHeightChanged"></a>QTable::rowHeightChanged ( int&nbsp;row )<tt> [virtual protected slot]</tt>
1053</h3>
1054This function should be called whenever the row height of <em>row</em>
1055has been changed. It updates the geometry of any affected rows and
1056repaints the table to reflect the changes it has made.
1057
1058<h3 class=fn>void <a name="rowIndexChanged"></a>QTable::rowIndexChanged ( int&nbsp;section, int&nbsp;fromIndex, int&nbsp;toIndex )<tt> [virtual protected slot]</tt>
1059</h3>
1060This function is called when the order of the rows is to be
1061changed, i.e. the user moved the row header section <em>section</em>
1062from <em>fromIndex</em> to <em>toIndex</em>.
1063<p> If you want to change the order programmatically, call <a href="#swapRows">swapRows</a>()
1064or <a href="#swapColumns">swapColumns</a>();
1065<p> <p>See also <a href="qheader.html#indexChange">QHeader::indexChange</a>() and <a href="#columnIndexChanged">columnIndexChanged</a>().
1066
1067<h3 class=fn>bool <a name="rowMovingEnabled"></a>QTable::rowMovingEnabled () const
1068</h3><p>Returns TRUE if rows can be moved by the user; otherwise returns FALSE.
1069See the <a href="qtable.html#rowMovingEnabled-prop">"rowMovingEnabled"</a> property for details.
1070<h3 class=fn>int <a name="rowPos"></a>QTable::rowPos ( int&nbsp;row ) const<tt> [virtual]</tt>
1071</h3>
1072Returns the y-coordinate of the row <em>row</em> in content coordinates.
1073<p> <p>See also <a href="#rowAt">rowAt</a>() and <a href="#columnPos">columnPos</a>().
1074
1075<h3 class=fn>void <a name="selectCells"></a>QTable::selectCells ( int&nbsp;start_row, int&nbsp;start_col, int&nbsp;end_row, int&nbsp;end_col )
1076</h3> Selects the range starting at <em>start_row</em> and <em>start_col</em> and
1077ending at <em>end_row</em> and <em>end_col</em>.
1078<p> <p>See also <a href="qtableselection.html">QTableSelection</a>.
1079
1080<h3 class=fn>void <a name="selectColumn"></a>QTable::selectColumn ( int&nbsp;col )
1081</h3> Selects the column <em>col</em>.
1082<p> <p>See also <a href="qtableselection.html">QTableSelection</a>.
1083
1084<h3 class=fn>void <a name="selectRow"></a>QTable::selectRow ( int&nbsp;row )
1085</h3> Selects the row <em>row</em>.
1086<p> <p>See also <a href="qtableselection.html">QTableSelection</a>.
1087
1088<h3 class=fn><a href="qtableselection.html">QTableSelection</a> <a name="selection"></a>QTable::selection ( int&nbsp;num ) const
1089</h3>
1090Returns selection number <em>num</em>, or an inactive <a href="qtableselection.html">QTableSelection</a> if <em>num</em> is out of range (see <a href="qtableselection.html#isActive">QTableSelection::isActive</a>()).
1091
1092<h3 class=fn>void <a name="selectionChanged"></a>QTable::selectionChanged ()<tt> [signal]</tt>
1093</h3>
1094
1095<p> This signal is emitted whenever a selection changes.
1096<p> <p>See also <a href="qtableselection.html">QTableSelection</a>.
1097
1098<h3 class=fn><a href="qtable.html#SelectionMode-enum">SelectionMode</a> <a name="selectionMode"></a>QTable::selectionMode () const
1099</h3><p>Returns the current selection mode.
1100See the <a href="qtable.html#selectionMode-prop">"selectionMode"</a> property for details.
1101<h3 class=fn>void <a name="setCellContentFromEditor"></a>QTable::setCellContentFromEditor ( int&nbsp;row, int&nbsp;col )<tt> [virtual protected]</tt>
1102</h3>
1103This function is called to replace the contents of the cell at <em>row</em>, <em>col</em> with the contents of the cell's editor.
1104<p> If there already exists a <a href="qtableitem.html">QTableItem</a> for the cell,
1105it calls <a href="qtableitem.html#setContentFromEditor">QTableItem::setContentFromEditor</a>() on this QTableItem.
1106<p> If, for example, you want to create different <a href="qtableitem.html">QTableItem</a>s
1107depending on the contents of the editor, you might reimplement
1108this function.
1109<p> If you want to work without <a href="qtableitem.html">QTableItem</a>s, you will need to
1110reimplement this function to save the data the user entered into
1111your data structure. (See the <a href="qtable.html#notes-on-large-tables">notes on large tables</a>.)
1112<p> <p>See also <a href="qtableitem.html#setContentFromEditor">QTableItem::setContentFromEditor</a>() and <a href="#createEditor">createEditor</a>().
1113
1114<h3 class=fn>void <a name="setCellWidget"></a>QTable::setCellWidget ( int&nbsp;row, int&nbsp;col, <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;e )<tt> [virtual]</tt>
1115</h3>
1116Sets the widget <em>e</em> to the cell at <em>row</em>, <em>col</em> and takes care of
1117placing and resizing the widget when the cell geometry changes.
1118<p> By default widgets are inserted into a vector with <a href="#numRows">numRows</a>() *
1119<a href="#numCols">numCols</a>() elements. In very large tables you will probably want to
1120store the widgets in a data structure that consumes less memory (see
1121the <a href="qtable.html#notes-on-large-tables">notes on large tables</a>). To support the use of your own data
1122structure this function calls <a href="#insertWidget">insertWidget</a>() to add the widget to
1123the internal data structure. To use your own data structure
1124reimplement insertWidget(), <a href="#cellWidget">cellWidget</a>() and <a href="#clearCellWidget">clearCellWidget</a>().
1125<p> Cell widgets are created dynamically with the <tt>new</tt> operator. The
1126cell widgets are destroyed automatically once the table is
1127destroyed; the table takes ownership of the widget when using
1128setCellWidget.
1129<p>
1130<p>Example: <a href="tutorial2-08.html#x2618">chart/setdataform.cpp</a>.
1131<h3 class=fn>void <a name="setColumnLabels"></a>QTable::setColumnLabels ( const&nbsp;<a href="qstringlist.html">QStringList</a>&nbsp;&amp;&nbsp;labels )<tt> [slot]</tt>
1132</h3> Sets the section labels of the <a href="#horizontalHeader">horizontalHeader</a>() to <em>labels</em>
1133<h3 class=fn>void <a name="setColumnMovingEnabled"></a>QTable::setColumnMovingEnabled ( bool&nbsp;b )<tt> [virtual slot]</tt>
1134</h3><p>Sets whether columns can be moved by the user to <em>b</em>.
1135See the <a href="qtable.html#columnMovingEnabled-prop">"columnMovingEnabled"</a> property for details.
1136<h3 class=fn>void <a name="setColumnReadOnly"></a>QTable::setColumnReadOnly ( int&nbsp;col, bool&nbsp;ro )<tt> [virtual slot]</tt>
1137</h3>
1138If <em>ro</em> is TRUE, column <em>col</em> is set to be read-only; otherwise
1139the column is set to be editable.
1140<p> Whether a cell in this column is editable or read-only depends on
1141the cell's EditType, and this setting:
1142see <a href="qtableitem.html#wheneditable">QTableItem::EditType</a>.
1143<p> <p>See also <a href="#isColumnReadOnly">isColumnReadOnly</a>(), <a href="#setRowReadOnly">setRowReadOnly</a>(), and <a href="#readOnly-prop">readOnly</a>.
1144
1145<p>
1146<p>Example: <a href="tutorial2-08.html#x2619">chart/setdataform.cpp</a>.
1147<h3 class=fn>void <a name="setColumnStretchable"></a>QTable::setColumnStretchable ( int&nbsp;col, bool&nbsp;stretch )<tt> [virtual slot]</tt>
1148</h3>
1149If <em>stretch</em> is TRUE, column <em>col</em> is set to be stretchable;
1150otherwise column <em>col</em> is set to be unstretchable.
1151<p> If the table widget's width decreases or increases stretchable
1152columns will grow narrower or wider to fit the space available as
1153completely as possible. The user cannot manually resize stretchable
1154columns.
1155<p> <p>See also <a href="#isColumnStretchable">isColumnStretchable</a>(), <a href="#setRowStretchable">setRowStretchable</a>(), and <a href="#adjustColumn">adjustColumn</a>().
1156
1157<h3 class=fn>void <a name="setColumnWidth"></a>QTable::setColumnWidth ( int&nbsp;col, int&nbsp;w )<tt> [virtual slot]</tt>
1158</h3>
1159Resizes column <em>col</em> to be <em>w</em> pixels wide.
1160<p> <p>See also <a href="#columnWidth">columnWidth</a>() and <a href="#setRowHeight">setRowHeight</a>().
1161
1162<p>Example: <a href="tutorial2-08.html#x2620">chart/setdataform.cpp</a>.
1163<p>Reimplemented in <a href="qdatatable.html#setColumnWidth">QDataTable</a>.
1164<h3 class=fn>void <a name="setCurrentCell"></a>QTable::setCurrentCell ( int&nbsp;row, int&nbsp;col )<tt> [virtual slot]</tt>
1165</h3>
1166Moves the focus to the cell at <em>row</em>, <em>col</em>.
1167<p> <p>See also <a href="#currentRow">currentRow</a>() and <a href="#currentColumn">currentColumn</a>().
1168
1169<h3 class=fn>void <a name="setDragEnabled"></a>QTable::setDragEnabled ( bool&nbsp;b )<tt> [virtual slot]</tt>
1170</h3>
1171If <em>b</em> is TRUE, the table starts a drag (see <a href="#dragObject">dragObject</a>()) when
1172the user presses and moves the mouse on a selected cell.
1173
1174<h3 class=fn>void <a name="setEditMode"></a>QTable::setEditMode ( <a href="qtable.html#EditMode-enum">EditMode</a>&nbsp;mode, int&nbsp;row, int&nbsp;col )<tt> [protected]</tt>
1175</h3>
1176Sets the current edit mode to <em>mode</em>, the current edit row to <em>row</em> and the current edit column to <em>col</em>.
1177<p> <p>See also <a href="#EditMode-enum">EditMode</a>.
1178
1179<h3 class=fn>void <a name="setFocusStyle"></a>QTable::setFocusStyle ( <a href="qtable.html#FocusStyle-enum">FocusStyle</a>&nbsp;fs )<tt> [virtual]</tt>
1180</h3><p>Sets how the current (focus) cell is drawn to <em>fs</em>.
1181See the <a href="qtable.html#focusStyle-prop">"focusStyle"</a> property for details.
1182<h3 class=fn>void <a name="setItem"></a>QTable::setItem ( int&nbsp;row, int&nbsp;col, <a href="qtableitem.html">QTableItem</a>&nbsp;*&nbsp;item )<tt> [virtual]</tt>
1183</h3>
1184Inserts the table item <em>item</em> into the table at row <em>row</em>,
1185column <em>col</em>, and repaints the cell. If a table item already
1186exists in this cell it is deleted and replaced with <em>item</em>. The
1187table takes ownership of the table item.
1188<p> If you don't use <a href="qtableitem.html">QTableItem</a>s you may need to reimplement this
1189function: see the <a href="qtable.html#notes-on-large-tables">notes on large tables</a>.
1190<p> <p>See also <a href="#item">item</a>() and <a href="#takeItem">takeItem</a>().
1191
1192<p>Examples: <a href="helpsystem-example.html#x2691">helpsystem/mainwindow.cpp</a> and <a href="small-table-example-example.html#x2803">table/small-table-demo/main.cpp</a>.
1193<h3 class=fn>void <a name="setLeftMargin"></a>QTable::setLeftMargin ( int&nbsp;m )<tt> [virtual slot]</tt>
1194</h3>
1195Sets the left margin to be <em>m</em> pixels wide.
1196<p> The <a href="#verticalHeader">verticalHeader</a>(), which displays row labels, occupies this
1197margin.
1198<p> In an Arabic or Hebrew <a href="i18n.html#localization">localization</a>, the verticalHeader() will
1199appear on the right side of the table, and this call will set the
1200right margin.
1201<p> <p>See also <a href="qscrollview.html#leftMargin">leftMargin</a>(), <a href="#setTopMargin">setTopMargin</a>(), and <a href="#verticalHeader">verticalHeader</a>().
1202
1203<p>Example: <a href="regexptester-example.html#x2501">regexptester/regexptester.cpp</a>.
1204<h3 class=fn>void <a name="setNumCols"></a>QTable::setNumCols ( int&nbsp;r )<tt> [virtual slot]</tt>
1205</h3><p>Sets the number of columns in the table to <em>r</em>.
1206See the <a href="qtable.html#numCols-prop">"numCols"</a> property for details.
1207<h3 class=fn>void <a name="setNumRows"></a>QTable::setNumRows ( int&nbsp;r )<tt> [virtual slot]</tt>
1208</h3><p>Sets the number of rows in the table to <em>r</em>.
1209See the <a href="qtable.html#numRows-prop">"numRows"</a> property for details.
1210<h3 class=fn>void <a name="setPixmap"></a>QTable::setPixmap ( int&nbsp;row, int&nbsp;col, const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;pix )<tt> [virtual]</tt>
1211</h3>
1212Sets the pixmap in the cell at <em>row</em>, <em>col</em> to <em>pix</em>.
1213<p> If the cell does not contain a table item a <a href="qtableitem.html">QTableItem</a> is created
1214with an <a href="qtableitem.html#EditType-enum">EditType</a> of <tt>OnTyping</tt>,
1215otherwise the existing table item's pixmap (if any) is replaced
1216with <em>pix</em>.
1217<p> Note that <a href="qcombotableitem.html">QComboTableItem</a>s and <a href="qchecktableitem.html">QCheckTableItem</a>s don't show
1218pixmaps.
1219<p> <p>See also <a href="#pixmap">pixmap</a>(), <a href="#setText">setText</a>(), <a href="#setItem">setItem</a>(), and <a href="qtableitem.html#setPixmap">QTableItem::setPixmap</a>().
1220
1221<p>Examples: <a href="tutorial2-08.html#x2623">chart/setdataform.cpp</a> and <a href="small-table-example-example.html#x2804">table/small-table-demo/main.cpp</a>.
1222<h3 class=fn>void <a name="setReadOnly"></a>QTable::setReadOnly ( bool&nbsp;b )<tt> [virtual slot]</tt>
1223</h3><p>Sets whether the table is read-only to <em>b</em>.
1224See the <a href="qtable.html#readOnly-prop">"readOnly"</a> property for details.
1225<h3 class=fn>void <a name="setRowHeight"></a>QTable::setRowHeight ( int&nbsp;row, int&nbsp;h )<tt> [virtual slot]</tt>
1226</h3>
1227Resizes row <em>row</em> to be <em>h</em> pixels high.
1228<p> <p>See also <a href="#rowHeight">rowHeight</a>() and <a href="#setColumnWidth">setColumnWidth</a>().
1229
1230<h3 class=fn>void <a name="setRowLabels"></a>QTable::setRowLabels ( const&nbsp;<a href="qstringlist.html">QStringList</a>&nbsp;&amp;&nbsp;labels )<tt> [slot]</tt>
1231</h3> Sets the section labels of the <a href="#verticalHeader">verticalHeader</a>() to <em>labels</em>
1232<h3 class=fn>void <a name="setRowMovingEnabled"></a>QTable::setRowMovingEnabled ( bool&nbsp;b )<tt> [virtual slot]</tt>
1233</h3><p>Sets whether rows can be moved by the user to <em>b</em>.
1234See the <a href="qtable.html#rowMovingEnabled-prop">"rowMovingEnabled"</a> property for details.
1235<h3 class=fn>void <a name="setRowReadOnly"></a>QTable::setRowReadOnly ( int&nbsp;row, bool&nbsp;ro )<tt> [virtual slot]</tt>
1236</h3>
1237If <em>ro</em> is TRUE, row <em>row</em> is set to be read-only; otherwise the
1238row is set to be editable.
1239<p> Whether a cell in this row is editable or read-only depends on the
1240cell's EditType, and this setting:
1241see <a href="qtableitem.html#wheneditable">QTableItem::EditType</a>.
1242<p> <p>See also <a href="#isRowReadOnly">isRowReadOnly</a>(), <a href="#setColumnReadOnly">setColumnReadOnly</a>(), and <a href="#readOnly-prop">readOnly</a>.
1243
1244<h3 class=fn>void <a name="setRowStretchable"></a>QTable::setRowStretchable ( int&nbsp;row, bool&nbsp;stretch )<tt> [virtual slot]</tt>
1245</h3>
1246If <em>stretch</em> is TRUE, row <em>row</em> is set to be stretchable;
1247otherwise row <em>row</em> is set to be unstretchable.
1248<p> If the table widget's height decreases or increases stretchable
1249rows will grow shorter or taller to fit the space available as
1250completely as possible. The user cannot manually resize
1251stretchable rows.
1252<p> <p>See also <a href="#isRowStretchable">isRowStretchable</a>() and <a href="#setColumnStretchable">setColumnStretchable</a>().
1253
1254<h3 class=fn>void <a name="setSelectionMode"></a>QTable::setSelectionMode ( <a href="qtable.html#SelectionMode-enum">SelectionMode</a>&nbsp;mode )<tt> [virtual]</tt>
1255</h3><p>Sets the current selection mode to <em>mode</em>.
1256See the <a href="qtable.html#selectionMode-prop">"selectionMode"</a> property for details.
1257<h3 class=fn>void <a name="setShowGrid"></a>QTable::setShowGrid ( bool&nbsp;b )<tt> [virtual slot]</tt>
1258</h3><p>Sets whether the table's grid is displayed to <em>b</em>.
1259See the <a href="qtable.html#showGrid-prop">"showGrid"</a> property for details.
1260<h3 class=fn>void <a name="setSorting"></a>QTable::setSorting ( bool&nbsp;b )<tt> [virtual slot]</tt>
1261</h3><p>Sets whether a click on the header of a column sorts that column to <em>b</em>.
1262See the <a href="qtable.html#sorting-prop">"sorting"</a> property for details.
1263<h3 class=fn>void <a name="setText"></a>QTable::setText ( int&nbsp;row, int&nbsp;col, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text )<tt> [virtual]</tt>
1264</h3>
1265Sets the text in the cell at <em>row</em>, <em>col</em> to <em>text</em>.
1266<p> If the cell does not contain a table item a <a href="qtableitem.html">QTableItem</a> is created
1267with an <a href="qtableitem.html#EditType-enum">EditType</a> of <tt>OnTyping</tt>,
1268otherwise the existing table item's text (if any) is replaced with
1269<em>text</em>.
1270<p> <p>See also <a href="#text">text</a>(), <a href="#setPixmap">setPixmap</a>(), <a href="#setItem">setItem</a>(), and <a href="qtableitem.html#setText">QTableItem::setText</a>().
1271
1272<p>Examples: <a href="tutorial2-08.html#x2624">chart/setdataform.cpp</a>, <a href="helpsystem-example.html#x2692">helpsystem/mainwindow.cpp</a>, <a href="regexptester-example.html#x2504">regexptester/regexptester.cpp</a>, and <a href="small-table-example-example.html#x2805">table/small-table-demo/main.cpp</a>.
1273<h3 class=fn>void <a name="setTopMargin"></a>QTable::setTopMargin ( int&nbsp;m )<tt> [virtual slot]</tt>
1274</h3>
1275Sets the top margin to be <em>m</em> pixels high.
1276<p> The <a href="#horizontalHeader">horizontalHeader</a>(), which displays column labels, occupies
1277this margin.
1278<p> <p>See also <a href="qscrollview.html#topMargin">topMargin</a>() and <a href="#setLeftMargin">setLeftMargin</a>().
1279
1280<p>Example: <a href="regexptester-example.html#x2505">regexptester/regexptester.cpp</a>.
1281<h3 class=fn>void <a name="showColumn"></a>QTable::showColumn ( int&nbsp;col )<tt> [virtual slot]</tt>
1282</h3>
1283Shows column <em>col</em>.
1284<p> <p>See also <a href="#hideColumn">hideColumn</a>() and <a href="#showRow">showRow</a>().
1285
1286<h3 class=fn>bool <a name="showGrid"></a>QTable::showGrid () const
1287</h3><p>Returns TRUE if the table's grid is displayed; otherwise returns FALSE.
1288See the <a href="qtable.html#showGrid-prop">"showGrid"</a> property for details.
1289<h3 class=fn>void <a name="showRow"></a>QTable::showRow ( int&nbsp;row )<tt> [virtual slot]</tt>
1290</h3>
1291Shows row <em>row</em>.
1292<p> <p>See also <a href="#hideRow">hideRow</a>() and <a href="#showColumn">showColumn</a>().
1293
1294<h3 class=fn>void <a name="sortColumn"></a>QTable::sortColumn ( int&nbsp;col, bool&nbsp;ascending = TRUE, bool&nbsp;wholeRows = FALSE )<tt> [virtual]</tt>
1295</h3>
1296Sorts column <em>col</em>. If <em>ascending</em> is TRUE the sort is in
1297ascending order, otherwise the sort is in descending order.
1298<p> If <em>wholeRows</em> is TRUE, entire rows are sorted using <a href="#swapRows">swapRows</a>();
1299otherwise only cells in the column are sorted using <a href="#swapCells">swapCells</a>().
1300<p> Note that if you are not using QTableItems you will need to
1301reimplement swapRows() and swapCells(). (See the <a href="qtable.html#notes-on-large-tables">notes on large tables</a>.)
1302<p> <p>See also <a href="#swapRows">swapRows</a>().
1303
1304<p>Example: <a href="statistics-example.html#x2784">table/statistics/statistics.cpp</a>.
1305<p>Reimplemented in <a href="qdatatable.html#sortColumn">QDataTable</a>.
1306<h3 class=fn>bool <a name="sorting"></a>QTable::sorting () const
1307</h3><p>Returns TRUE if a click on the header of a column sorts that column; otherwise returns FALSE.
1308See the <a href="qtable.html#sorting-prop">"sorting"</a> property for details.
1309<h3 class=fn>void <a name="startDrag"></a>QTable::startDrag ()<tt> [virtual protected]</tt>
1310</h3>
1311Starts a drag.
1312<p> Usually you don't need to call or reimplement this function yourself.
1313<p> <p>See also <a href="#dragObject">dragObject</a>().
1314
1315<h3 class=fn>void <a name="swapCells"></a>QTable::swapCells ( int&nbsp;row1, int&nbsp;col1, int&nbsp;row2, int&nbsp;col2 )<tt> [virtual slot]</tt>
1316</h3>
1317Swaps the contents of the cell at <em>row1</em>, <em>col1</em> with the
1318contents of the cell at <em>row2</em>, <em>col2</em>.
1319<p> This function is also called when the table is sorted.
1320<p> If you don't use <a href="qtableitem.html">QTableItem</a>s and want your users to be able to
1321swap cells, you will need to reimplement this function. (See the
1322<a href="qtable.html#notes-on-large-tables">notes on large tables</a>.)
1323<p> <p>See also <a href="#swapColumns">swapColumns</a>() and <a href="#swapRows">swapRows</a>().
1324
1325<h3 class=fn>void <a name="swapColumns"></a>QTable::swapColumns ( int&nbsp;col1, int&nbsp;col2, bool&nbsp;swapHeader = FALSE )<tt> [virtual slot]</tt>
1326</h3>
1327Swaps the data in <em>col1</em> with <em>col2</em>.
1328<p> This function is used to swap the positions of two columns. It is
1329called when the user changes the order of columns (see
1330<a href="#setColumnMovingEnabled">setColumnMovingEnabled</a>(), and when columns are sorted.
1331<p> If you don't use <a href="qtableitem.html">QTableItem</a>s and want your users to be able to
1332swap columns you will need to reimplement this function. (See the
1333<a href="qtable.html#notes-on-large-tables">notes on large tables</a>.)
1334<p> If <em>swapHeader</em> is TRUE, the columns' header contents is also
1335swapped.
1336<p> <p>See also <a href="#swapCells">swapCells</a>().
1337
1338<h3 class=fn>void <a name="swapRows"></a>QTable::swapRows ( int&nbsp;row1, int&nbsp;row2, bool&nbsp;swapHeader = FALSE )<tt> [virtual slot]</tt>
1339</h3>
1340Swaps the data in <em>row1</em> and <em>row2</em>.
1341<p> This function is used to swap the positions of two rows. It is
1342called when the user changes the order of rows (see
1343<a href="#setRowMovingEnabled">setRowMovingEnabled</a>()), and when rows are sorted.
1344<p> If you don't use <a href="qtableitem.html">QTableItem</a>s and want your users to be able to
1345swap rows, e.g. for sorting, you will need to reimplement this
1346function. (See the <a href="qtable.html#notes-on-large-tables">notes on large tables</a>.)
1347<p> If <em>swapHeader</em> is TRUE, the rows' header contents is also
1348swapped.
1349<p> This function will not update the QTable, you will have to do
1350this manually, e.g. by calling <a href="qscrollview.html#updateContents">updateContents</a>().
1351<p> <p>See also <a href="#swapColumns">swapColumns</a>() and <a href="#swapCells">swapCells</a>().
1352
1353<h3 class=fn>void <a name="takeItem"></a>QTable::takeItem ( <a href="qtableitem.html">QTableItem</a>&nbsp;*&nbsp;i )<tt> [virtual]</tt>
1354</h3>
1355Takes the table item <em>i</em> out of the table. This function does <em>not</em> delete the table item. You must either delete the table item
1356yourself or put it into a table (using <a href="#setItem">setItem</a>()) which will then
1357take ownership of it.
1358<p> Use this function if you want to move an item from one cell in a
1359table to another, or to move an item from one table to another,
1360reinserting the item with setItem().
1361<p> If you want to exchange two cells use <a href="#swapCells">swapCells</a>().
1362
1363<h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QTable::text ( int&nbsp;row, int&nbsp;col ) const<tt> [virtual]</tt>
1364</h3>
1365Returns the text in the cell at <em>row</em>, <em>col</em>, or <a href="qstring.html#QString-null">QString::null</a>
1366if the relevant item does not exist or has no text.
1367<p> <p>See also <a href="#setText">setText</a>() and <a href="#setPixmap">setPixmap</a>().
1368
1369<p>Example: <a href="tutorial2-08.html#x2625">chart/setdataform.cpp</a>.
1370<p>Reimplemented in <a href="qdatatable.html#text">QDataTable</a>.
1371<h3 class=fn>void <a name="updateCell"></a>QTable::updateCell ( int&nbsp;row, int&nbsp;col )
1372</h3>
1373Repaints the cell at <em>row</em>, <em>col</em>.
1374
1375<h3 class=fn>void <a name="updateHeaderStates"></a>QTable::updateHeaderStates ()
1376</h3>
1377This functions updates all the header states to be in sync with
1378the current selections. This should be called after
1379programatically changing, adding or removing selections, so that
1380the headers are updated.
1381
1382<h3 class=fn>void <a name="valueChanged"></a>QTable::valueChanged ( int&nbsp;row, int&nbsp;col )<tt> [signal]</tt>
1383</h3>
1384
1385<p> This signal is emitted when the user changed the value in the cell
1386at <em>row</em>, <em>col</em>.
1387
1388<p>Example: <a href="tutorial2-08.html#x2626">chart/setdataform.cpp</a>.
1389<h3 class=fn><a href="qheader.html">QHeader</a>&nbsp;* <a name="verticalHeader"></a>QTable::verticalHeader () const
1390</h3>
1391Returns the table's vertical <a href="qheader.html">QHeader</a>.
1392<p> This header contains the row labels.
1393<p> <p>See also <a href="#horizontalHeader">horizontalHeader</a>(), <a href="#setLeftMargin">setLeftMargin</a>(), and <a href="qheader.html">QHeader</a>.
1394
1395<p>Examples: <a href="helpsystem-example.html#x2693">helpsystem/mainwindow.cpp</a> and <a href="regexptester-example.html#x2506">regexptester/regexptester.cpp</a>.
1396<hr><h2>Property Documentation</h2>
1397<h3 class=fn>bool <a name="columnMovingEnabled-prop"></a>columnMovingEnabled</h3>
1398<p>This property holds whether columns can be moved by the user.
1399<p>The default is FALSE. Columns are moved by dragging whilst holding
1400down the Ctrl key.
1401<p> <b>Warning:</b> If QTable is used to move header sections as a result of user
1402interaction, the mapping between header indexes and section exposed by
1403<a href="qheader.html">QHeader</a> will not reflect the order of the headers in the table; i.e.,
1404QTable does not call <a href="qheader.html#moveSection">QHeader::moveSection</a>() to move sections but handles
1405move operations internally.
1406<p> <p>See also <a href="#rowMovingEnabled-prop">rowMovingEnabled</a>.
1407
1408<p>Set this property's value with <a href="#setColumnMovingEnabled">setColumnMovingEnabled</a>() and get this property's value with <a href="#columnMovingEnabled">columnMovingEnabled</a>().
1409<h3 class=fn><a href="qtable.html#FocusStyle-enum">FocusStyle</a> <a name="focusStyle-prop"></a>focusStyle</h3>
1410<p>This property holds how the current (focus) cell is drawn.
1411<p>The default style is <a href="#FocusStyle-enum">SpreadSheet</a>.
1412<p> <p>See also <a href="#FocusStyle-enum">QTable::FocusStyle</a>.
1413
1414<p>Set this property's value with <a href="#setFocusStyle">setFocusStyle</a>() and get this property's value with <a href="#focusStyle">focusStyle</a>().
1415<h3 class=fn>int <a name="numCols-prop"></a>numCols</h3>
1416<p>This property holds the number of columns in the table.
1417<p>Set this property's value with <a href="#setNumCols">setNumCols</a>() and get this property's value with <a href="#numCols">numCols</a>().
1418<p><p>See also <a href="#numRows-prop">numRows</a>.
1419
1420<h3 class=fn>int <a name="numRows-prop"></a>numRows</h3>
1421<p>This property holds the number of rows in the table.
1422<p>Set this property's value with <a href="#setNumRows">setNumRows</a>() and get this property's value with <a href="#numRows">numRows</a>().
1423<p><p>See also <a href="#numCols-prop">numCols</a>.
1424
1425<h3 class=fn>int <a name="numSelections-prop"></a>numSelections</h3>
1426<p>This property holds the number of selections.
1427<p>Get this property's value with <a href="#numSelections">numSelections</a>().
1428<p><p>See also <a href="#currentSelection">currentSelection</a>().
1429
1430<h3 class=fn>bool <a name="readOnly-prop"></a>readOnly</h3>
1431<p>This property holds whether the table is read-only.
1432<p>Whether a cell in the table is editable or read-only depends on
1433the cell's <a href="qtableitem.html#EditType-enum">EditType</a>, and this setting:
1434see <a href="qtableitem.html#wheneditable">QTableItem::EditType</a>.
1435<p> <p>See also <a href="qwidget.html#enabled-prop">QWidget::enabled</a>, <a href="#setColumnReadOnly">setColumnReadOnly</a>(), and <a href="#setRowReadOnly">setRowReadOnly</a>().
1436
1437<p>Set this property's value with <a href="#setReadOnly">setReadOnly</a>() and get this property's value with <a href="#isReadOnly">isReadOnly</a>().
1438<h3 class=fn>bool <a name="rowMovingEnabled-prop"></a>rowMovingEnabled</h3>
1439<p>This property holds whether rows can be moved by the user.
1440<p>The default is FALSE. Rows are moved by dragging whilst holding
1441down the Ctrl key.
1442<p> <b>Warning:</b> If QTable is used to move header sections as a result of user
1443interaction, the mapping between header indexes and section exposed by
1444<a href="qheader.html">QHeader</a> will not reflect the order of the headers in the table; i.e.,
1445QTable does not call <a href="qheader.html#moveSection">QHeader::moveSection</a>() to move sections but handles
1446move operations internally.
1447<p> <p>See also <a href="#columnMovingEnabled-prop">columnMovingEnabled</a>.
1448
1449<p>Set this property's value with <a href="#setRowMovingEnabled">setRowMovingEnabled</a>() and get this property's value with <a href="#rowMovingEnabled">rowMovingEnabled</a>().
1450<h3 class=fn><a href="qtable.html#SelectionMode-enum">SelectionMode</a> <a name="selectionMode-prop"></a>selectionMode</h3>
1451<p>This property holds the current selection mode.
1452<p>The default mode is <a href="#SelectionMode-enum">Multi</a> which allows the user to select
1453multiple ranges of cells.
1454<p> <p>See also <a href="#SelectionMode-enum">SelectionMode</a> and <a href="#selectionMode-prop">selectionMode</a>.
1455
1456<p>Set this property's value with <a href="#setSelectionMode">setSelectionMode</a>() and get this property's value with <a href="#selectionMode">selectionMode</a>().
1457<h3 class=fn>bool <a name="showGrid-prop"></a>showGrid</h3>
1458<p>This property holds whether the table's grid is displayed.
1459<p>The grid is shown by default.
1460
1461<p>Set this property's value with <a href="#setShowGrid">setShowGrid</a>() and get this property's value with <a href="#showGrid">showGrid</a>().
1462<h3 class=fn>bool <a name="sorting-prop"></a>sorting</h3>
1463<p>This property holds whether a click on the header of a column sorts that column.
1464<p>Set this property's value with <a href="#setSorting">setSorting</a>() and get this property's value with <a href="#sorting">sorting</a>().
1465<p><p>See also <a href="#sortColumn">sortColumn</a>().
1466
1467<!-- eof -->
1468<hr><p>
1469This file is part of the <a href="index.html">Qt toolkit</a>.
1470Copyright &copy; 1995-2007
1471<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
1472<table width=100% cellspacing=0 border=0><tr>
1473<td>Copyright &copy; 2007
1474<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
1475<td align=right><div align=right>Qt 3.3.8</div>
1476</table></div></address></body>
1477</html>
Note: See TracBrowser for help on using the repository browser.