source: trunk/doc/html/qtableitem.html@ 208

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

reference documentation added

File size: 28.8 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:406 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QTableItem 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>QTableItem Class Reference<br><small>[<a href="table.html">table module</a>]</small></h1>
33
34<p>The QTableItem class provides the cell content for QTable cells.
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="qt.html">Qt</a>.
38<p>Inherited by <a href="qcombotableitem.html">QComboTableItem</a> and <a href="qchecktableitem.html">QCheckTableItem</a>.
39<p><a href="qtableitem-members.html">List of all member functions.</a>
40<h2>Public Members</h2>
41<ul>
42<li class=fn>enum <a href="#EditType-enum"><b>EditType</b></a> { Never, OnTyping, WhenCurrent, Always }</li>
43<li class=fn><a href="#QTableItem"><b>QTableItem</b></a> ( QTable&nbsp;*&nbsp;table, EditType&nbsp;et )</li>
44<li class=fn><a href="#QTableItem-2"><b>QTableItem</b></a> ( QTable&nbsp;*&nbsp;table, EditType&nbsp;et, const&nbsp;QString&nbsp;&amp;&nbsp;text )</li>
45<li class=fn><a href="#QTableItem-3"><b>QTableItem</b></a> ( QTable&nbsp;*&nbsp;table, EditType&nbsp;et, const&nbsp;QString&nbsp;&amp;&nbsp;text, const&nbsp;QPixmap&nbsp;&amp;&nbsp;p )</li>
46<li class=fn>virtual <a href="#~QTableItem"><b>~QTableItem</b></a> ()</li>
47<li class=fn>virtual QPixmap <a href="#pixmap"><b>pixmap</b></a> () const</li>
48<li class=fn>virtual QString <a href="#text"><b>text</b></a> () const</li>
49<li class=fn>virtual void <a href="#setPixmap"><b>setPixmap</b></a> ( const&nbsp;QPixmap&nbsp;&amp;&nbsp;p )</li>
50<li class=fn>virtual void <a href="#setText"><b>setText</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;str )</li>
51<li class=fn>QTable * <a href="#table"><b>table</b></a> () const</li>
52<li class=fn>virtual int <a href="#alignment"><b>alignment</b></a> () const</li>
53<li class=fn>virtual void <a href="#setWordWrap"><b>setWordWrap</b></a> ( bool&nbsp;b )</li>
54<li class=fn>bool <a href="#wordWrap"><b>wordWrap</b></a> () const</li>
55<li class=fn>EditType <a href="#editType"><b>editType</b></a> () const</li>
56<li class=fn>virtual QWidget * <a href="#createEditor"><b>createEditor</b></a> () const</li>
57<li class=fn>virtual void <a href="#setContentFromEditor"><b>setContentFromEditor</b></a> ( QWidget&nbsp;*&nbsp;w )</li>
58<li class=fn>virtual void <a href="#setReplaceable"><b>setReplaceable</b></a> ( bool&nbsp;b )</li>
59<li class=fn>bool <a href="#isReplaceable"><b>isReplaceable</b></a> () const</li>
60<li class=fn>virtual QString <a href="#key"><b>key</b></a> () const</li>
61<li class=fn>virtual QSize <a href="#sizeHint"><b>sizeHint</b></a> () const</li>
62<li class=fn>virtual void <a href="#setSpan"><b>setSpan</b></a> ( int&nbsp;rs, int&nbsp;cs )</li>
63<li class=fn>int <a href="#rowSpan"><b>rowSpan</b></a> () const</li>
64<li class=fn>int <a href="#colSpan"><b>colSpan</b></a> () const</li>
65<li class=fn>virtual void <a href="#setRow"><b>setRow</b></a> ( int&nbsp;r )</li>
66<li class=fn>virtual void <a href="#setCol"><b>setCol</b></a> ( int&nbsp;c )</li>
67<li class=fn>int <a href="#row"><b>row</b></a> () const</li>
68<li class=fn>int <a href="#col"><b>col</b></a> () const</li>
69<li class=fn>virtual void <a href="#paint"><b>paint</b></a> ( QPainter&nbsp;*&nbsp;p, const&nbsp;QColorGroup&nbsp;&amp;&nbsp;cg, const&nbsp;QRect&nbsp;&amp;&nbsp;cr, bool&nbsp;selected )</li>
70<li class=fn>virtual void <a href="#setEnabled"><b>setEnabled</b></a> ( bool&nbsp;b )</li>
71<li class=fn>bool <a href="#isEnabled"><b>isEnabled</b></a> () const</li>
72<li class=fn>virtual int <a href="#rtti"><b>rtti</b></a> () const</li>
73</ul>
74<hr><a name="details"></a><h2>Detailed Description</h2>
75
76
77The QTableItem class provides the cell content for <a href="qtable.html">QTable</a> cells.
78
79<p>
80
81<p> For many applications QTableItems are ideal for presenting and
82editing the contents of QTable cells. In situations where you need
83to create very large tables you may prefer an alternative approach
84to using QTableItems: see the <a href="qtable.html#notes-on-large-tables">notes on large tables</a>.
85<p> A QTableItem contains a cell's data, by default, a string and a
86pixmap. The table item also holds the cell's display size and how
87the data should be aligned. The table item specifies the cell's
88<a href="#EditType-enum">EditType</a> and the editor used for in-place editing (by default a
89<a href="qlineedit.html">QLineEdit</a>). If you want checkboxes use <a href="qchecktableitem.html">QCheckTableItem</a>, and if
90you want comboboxes use <a href="qcombotableitem.html">QComboTableItem</a>. The <a href="#EditType-enum">EditType</a> (set
91in the constructor) determines whether the cell's contents may be
92edited.
93<p> If a pixmap is specified it is displayed to the left of any text.
94You can change the text or pixmap with <a href="#setText">setText</a>() and <a href="#setPixmap">setPixmap</a>()
95respectively. For text you can use <a href="#setWordWrap">setWordWrap</a>().
96<p> When sorting table items the <a href="#key">key</a>() function is used; by default
97this returns the table item's <a href="#text">text</a>(). Reimplement key() to
98customize how your table items will sort.
99<p> Table items are inserted into a table using <a href="qtable.html#setItem">QTable::setItem</a>(). If
100you insert an item into a cell that already contains a table item
101the original item will be deleted.
102<p> Example:
103<pre>
104 for ( int row = 0; row &lt; table-&gt;numRows(); row++ ) {
105 for ( int col = 0; col &lt; table-&gt;numCols(); col++ ) {
106 table-&gt;setItem( row, col,
107 new QTableItem( table, QTableItem::<a href="#EditType-enum">WhenCurrent</a>, QString::number( row * col ) ) );
108 }
109 }
110 </pre>
111
112<p> You can move a table item from one cell to another, in the same or
113a different table, using <a href="qtable.html#takeItem">QTable::takeItem</a>() and QTable::setItem()
114but see also <a href="qtable.html#swapCells">QTable::swapCells</a>().
115<p> Table items can be deleted with delete in the standard way; the
116table and cell will be updated accordingly.
117<p> Note, that if you have a table item that is not currently in a table
118then anything you do to that item other than insert it into a table
119will result in undefined behaviour.
120<p> Reimplement <a href="#createEditor">createEditor</a>() and <a href="#setContentFromEditor">setContentFromEditor</a>() if you want
121to use your own widget instead of a <a href="qlineedit.html">QLineEdit</a> for editing cell
122contents. Reimplement <a href="#paint">paint</a>() if you want to display custom
123content.
124<p> It is important to ensure that your custom widget can accept the
125<a href="focus.html#keyboard-focus">keyboard focus</a>, so that the user can use the tab key to navigate the
126table as normal. Therefore, if the widget returned by createEditor()
127does not itself accept the keyboard focus, it is necessary to
128nominate a child widget to do so on its behalf. For example, a
129<a href="qhbox.html">QHBox</a> with two child QLineEdit widgets may use one of them to
130accept the keyboard focus:
131<p> <pre>
132 QWidget* MyTableItem::createEditor() const
133 {
134 <a href="qhbox.html">QHBox</a>* hbox = new <a href="qhbox.html">QHBox</a>( <a href="#table">table</a>()-&gt;viewport() );
135 hbox-&gt;<a href="qwidget.html#setFocusProxy">setFocusProxy</a>(new <a href="qlineedit.html">QLineEdit</a>( hbox ));
136 new <a href="qlineedit.html">QLineEdit</a>( hbox );
137 return hbox;
138 }
139 </pre>
140
141<p> By default, table items may be replaced by new QTableItems
142during the lifetime of a <a href="qtable.html">QTable</a>. Therefore, if you create your
143own subclass of QTableItem, and you want to ensure that
144this does not happen, you must call <a href="#setReplaceable">setReplaceable</a>(FALSE)
145in the constructor of your subclass.
146<p> <center><img src="qtableitems.png" alt="Table Items"></center>
147<p> <p>See also <a href="qchecktableitem.html">QCheckTableItem</a>, <a href="qcombotableitem.html">QComboTableItem</a>, and <a href="advanced.html">Advanced Widgets</a>.
148
149<p>
150<hr><h2>Member Type Documentation</h2>
151<h3 class=fn><a name="EditType-enum"></a>QTableItem::EditType</h3>
152
153<p> <a name="wheneditable"></a>
154This enum is used to define whether a cell is editable or
155read-only (in conjunction with other settings), and how the cell
156should be displayed.
157<ul>
158<li><tt>QTableItem::Always</tt> -
159The cell always <em>looks</em> editable.
160</ul><p> Using this EditType ensures that the editor created with
161<a href="#createEditor">createEditor</a>() (by default a <a href="qlineedit.html">QLineEdit</a>) is always visible. This
162has implications for the alignment of the content: the default
163editor aligns everything (even numbers) to the left whilst
164numerical values in the cell are by default aligned to the right.
165<p> If a cell with the edit type <a href="#EditType-enum">Always</a> looks misaligned you could
166reimplement createEditor() for these items.
167<ul>
168<li><tt>QTableItem::WhenCurrent</tt> -
169The cell <em>looks</em> editable only when it has <a href="focus.html#keyboard-focus">keyboard focus</a> (see
170<a href="qtable.html#setCurrentCell">QTable::setCurrentCell</a>()).
171<li><tt>QTableItem::OnTyping</tt> -
172The cell <em>looks</em> editable only when the user types in it or
173double-clicks it. It resembles the <a href="#EditType-enum">WhenCurrent</a> functionality
174but is, perhaps, nicer.
175</ul><p> The <a href="#EditType-enum">OnTyping</a> edit type is the default when QTableItem objects
176are created by the convenience functions <a href="qtable.html#setText">QTable::setText</a>() and
177<a href="qtable.html#setPixmap">QTable::setPixmap</a>().
178<ul>
179<li><tt>QTableItem::Never</tt> - The cell is not editable.
180</ul><p> The cell is actually editable only if <a href="qtable.html#isRowReadOnly">QTable::isRowReadOnly</a>() is
181FALSE for its row, <a href="qtable.html#isColumnReadOnly">QTable::isColumnReadOnly</a>() is FALSE for its
182column, and <a href="qtable.html#isReadOnly">QTable::isReadOnly</a>() is FALSE.
183<p> QComboTableItems have an isEditable() property. This property is
184used to indicate whether the user may enter their own text or are
185restricted to choosing one of the choices in the list.
186QComboTableItems may be interacted with only if they are editable
187in accordance with their EditType as described above.
188<p>
189<hr><h2>Member Function Documentation</h2>
190<h3 class=fn><a name="QTableItem"></a>QTableItem::QTableItem ( <a href="qtable.html">QTable</a>&nbsp;*&nbsp;table, <a href="qtableitem.html#EditType-enum">EditType</a>&nbsp;et )
191</h3>
192Creates a table item that is a child of table <em>table</em> with no
193text. The item has the <a href="#EditType-enum">EditType</a> <em>et</em>.
194<p> The table item will use a <a href="qlineedit.html">QLineEdit</a> for its editor, will not
195word-wrap and will occupy a single cell. Insert the table item
196into a table with <a href="qtable.html#setItem">QTable::setItem</a>().
197<p> The table takes ownership of the table item, so a table item
198should not be inserted into more than one table at a time.
199
200<h3 class=fn><a name="QTableItem-2"></a>QTableItem::QTableItem ( <a href="qtable.html">QTable</a>&nbsp;*&nbsp;table, <a href="qtableitem.html#EditType-enum">EditType</a>&nbsp;et, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text )
201</h3>
202Creates a table item that is a child of table <em>table</em> with text
203<em>text</em>. The item has the <a href="#EditType-enum">EditType</a> <em>et</em>.
204<p> The table item will use a <a href="qlineedit.html">QLineEdit</a> for its editor, will not
205word-wrap and will occupy a single cell. Insert the table item
206into a table with <a href="qtable.html#setItem">QTable::setItem</a>().
207<p> The table takes ownership of the table item, so a table item
208should not be inserted into more than one table at a time.
209
210<h3 class=fn><a name="QTableItem-3"></a>QTableItem::QTableItem ( <a href="qtable.html">QTable</a>&nbsp;*&nbsp;table, <a href="qtableitem.html#EditType-enum">EditType</a>&nbsp;et, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;text, const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;p )
211</h3>
212Creates a table item that is a child of table <em>table</em> with text
213<em>text</em> and pixmap <em>p</em>. The item has the <a href="#EditType-enum">EditType</a> <em>et</em>.
214<p> The table item will display the pixmap to the left of the text. It
215will use a <a href="qlineedit.html">QLineEdit</a> for editing the text, will not word-wrap and
216will occupy a single cell. Insert the table item into a table with
217<a href="qtable.html#setItem">QTable::setItem</a>().
218<p> The table takes ownership of the table item, so a table item
219should not be inserted in more than one table at a time.
220
221<h3 class=fn><a name="~QTableItem"></a>QTableItem::~QTableItem ()<tt> [virtual]</tt>
222</h3>
223The destructor deletes this item and frees all allocated
224resources.
225<p> If the table item is in a table (i.e. was inserted with
226setItem()), it will be removed from the table and the cell it
227occupied.
228
229<h3 class=fn>int <a name="alignment"></a>QTableItem::alignment () const<tt> [virtual]</tt>
230</h3>
231The alignment function returns how the text contents of the cell
232are aligned when drawn. The default implementation aligns numbers
233to the right and any other text to the left.
234<p> <p>See also <a href="qt.html#AlignmentFlags-enum">Qt::AlignmentFlags</a>.
235
236<h3 class=fn>int <a name="col"></a>QTableItem::col () const
237</h3>
238Returns the column where the table item is located. If the cell
239spans multiple columns, this function returns the left-most
240column.
241<p> <p>See also <a href="#row">row</a>() and <a href="#setCol">setCol</a>().
242
243<p>Example: <a href="bigtable-example.html#x1293">table/bigtable/main.cpp</a>.
244<h3 class=fn>int <a name="colSpan"></a>QTableItem::colSpan () const
245</h3>
246Returns the column span of the table item, usually 1.
247<p> <p>See also <a href="#setSpan">setSpan</a>() and <a href="#rowSpan">rowSpan</a>().
248
249<h3 class=fn><a href="qwidget.html">QWidget</a>&nbsp;* <a name="createEditor"></a>QTableItem::createEditor () const<tt> [virtual]</tt>
250</h3>
251This virtual function creates an editor which the user can
252interact with to edit the cell's contents. The default
253implementation creates a <a href="qlineedit.html">QLineEdit</a>.
254<p> If the function returns 0, the cell is read-only.
255<p> The returned widget should preferably be invisible, ideally with
256<a href="qscrollview.html#viewport">QTable::viewport</a>() as parent.
257<p> If you reimplement this function you'll almost certainly need to
258reimplement <a href="#setContentFromEditor">setContentFromEditor</a>(), and may need to reimplement
259<a href="#sizeHint">sizeHint</a>().
260<p>
261
262<pre> <a name="x2444"></a>QWidget *ComboItem::<a href="#createEditor">createEditor</a>() const
263 {
264 // create an editor - a combobox in our case
265 ( (ComboItem*)this )-&gt;cb = new <a href="qcombobox.html">QComboBox</a>( <a href="#table">table</a>()-&gt;viewport() );
266 QObject::<a href="qobject.html#connect">connect</a>( cb, SIGNAL( activated( int ) ), table(), SLOT( doValueChanged() ) );
267 cb-&gt;insertItem( "Yes" );
268 cb-&gt;insertItem( "No" );
269 // and initialize it
270 cb-&gt;setCurrentItem( <a href="#text">text</a>() == "No" ? 1 : 0 );
271 return cb;
272</pre>
273<p> <p>See also <a href="qtable.html#createEditor">QTable::createEditor</a>(), <a href="#setContentFromEditor">setContentFromEditor</a>(), <a href="qscrollview.html#viewport">QTable::viewport</a>(), and <a href="#setReplaceable">setReplaceable</a>().
274
275<p>Example: <a href="qtableitem.html#x2444">table/statistics/statistics.cpp</a>.
276<h3 class=fn><a href="qtableitem.html#EditType-enum">EditType</a> <a name="editType"></a>QTableItem::editType () const
277</h3>
278Returns the table item's edit type.
279<p> This is set when the table item is constructed.
280<p> <p>See also <a href="#EditType-enum">EditType</a> and <a href="#QTableItem">QTableItem</a>().
281
282<h3 class=fn>bool <a name="isEnabled"></a>QTableItem::isEnabled () const
283</h3>
284Returns TRUE if the table item is enabled; otherwise returns FALSE.
285<p> <p>See also <a href="#setEnabled">setEnabled</a>().
286
287<h3 class=fn>bool <a name="isReplaceable"></a>QTableItem::isReplaceable () const
288</h3>
289This function returns whether the contents of the cell may be
290replaced with the contents of another table item. Regardless of
291this setting, table items that span more than one cell may not
292have their contents replaced by another table item.
293<p> (This differs from <a href="#EditType-enum">EditType</a> because EditType is concerned with
294whether the <em>user</em> is able to change the contents of a cell.)
295<p> <p>See also <a href="#setReplaceable">setReplaceable</a>() and <a href="#EditType-enum">EditType</a>.
296
297<h3 class=fn><a href="qstring.html">QString</a> <a name="key"></a>QTableItem::key () const<tt> [virtual]</tt>
298</h3>
299This virtual function returns the key that should be used for
300sorting. The default implementation returns the <a href="#text">text</a>() of the
301relevant item.
302<p> <p>See also <a href="qtable.html#sorting-prop">QTable::sorting</a>.
303
304<h3 class=fn>void <a name="paint"></a>QTableItem::paint ( <a href="qpainter.html">QPainter</a>&nbsp;*&nbsp;p, const&nbsp;<a href="qcolorgroup.html">QColorGroup</a>&nbsp;&amp;&nbsp;cg, const&nbsp;<a href="qrect.html">QRect</a>&nbsp;&amp;&nbsp;cr, bool&nbsp;selected )<tt> [virtual]</tt>
305</h3>
306This virtual function is used to paint the contents of an item
307using the painter <em>p</em> in the rectangular area <em>cr</em> using the
308color group <em>cg</em>.
309<p> If <em>selected</em> is TRUE the cell is displayed in a way that
310indicates that it is highlighted.
311<p> You don't usually need to use this function but if you want to
312draw custom content in a cell you will need to reimplement it.
313<p> The painter passed to this function is translated so that 0, 0
314is the top-left corner of the item that is being painted.
315<p> Note that the painter is not clipped by default in order to get
316maximum efficiency. If you want clipping, use
317<p> <pre>
318 p-&gt;setClipRect( <a href="#table">table</a>()-&gt;cellRect(row, col), QPainter::ClipPainter );
319 //... your drawing code
320 p-&gt;setClipping( FALSE );
321 </pre>
322
323<p>
324<p>Example: <a href="statistics-example.html#x2786">table/statistics/statistics.cpp</a>.
325<h3 class=fn><a href="qpixmap.html">QPixmap</a> <a name="pixmap"></a>QTableItem::pixmap () const<tt> [virtual]</tt>
326</h3>
327Returns the table item's pixmap or a null pixmap if no pixmap has
328been set.
329<p> <p>See also <a href="#setPixmap">setPixmap</a>() and <a href="#text">text</a>().
330
331<h3 class=fn>int <a name="row"></a>QTableItem::row () const
332</h3>
333Returns the row where the table item is located. If the cell spans
334multiple rows, this function returns the top-most row.
335<p> <p>See also <a href="#col">col</a>() and <a href="#setRow">setRow</a>().
336
337<p>Example: <a href="bigtable-example.html#x1294">table/bigtable/main.cpp</a>.
338<h3 class=fn>int <a name="rowSpan"></a>QTableItem::rowSpan () const
339</h3>
340Returns the row span of the table item, usually 1.
341<p> <p>See also <a href="#setSpan">setSpan</a>() and <a href="#colSpan">colSpan</a>().
342
343<h3 class=fn>int <a name="rtti"></a>QTableItem::rtti () const<tt> [virtual]</tt>
344</h3>
345Returns the Run Time Type Identification value for this table item
346which for QTableItems is 0.
347<p> When you create subclasses based on QTableItem make sure that each
348subclass returns a unique <a href="#rtti">rtti</a>() value. It is advisable to use
349values greater than 1000, preferably large random numbers, to
350allow for extensions to this class.
351<p> <p>See also <a href="qchecktableitem.html#rtti">QCheckTableItem::rtti</a>() and <a href="qcombotableitem.html#rtti">QComboTableItem::rtti</a>().
352
353<p>Reimplemented in <a href="qcombotableitem.html#rtti">QComboTableItem</a> and <a href="qchecktableitem.html#rtti">QCheckTableItem</a>.
354<h3 class=fn>void <a name="setCol"></a>QTableItem::setCol ( int&nbsp;c )<tt> [virtual]</tt>
355</h3>
356Sets column <em>c</em> as the table item's column. Usually you will not
357need to call this function.
358<p> If the cell spans multiple columns, this function sets the
359left-most column and retains the width of the multi-cell table
360item.
361<p> <p>See also <a href="#col">col</a>(), <a href="#setRow">setRow</a>(), and <a href="#colSpan">colSpan</a>().
362
363<h3 class=fn>void <a name="setContentFromEditor"></a>QTableItem::setContentFromEditor ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;w )<tt> [virtual]</tt>
364</h3>
365Whenever the content of a cell has been edited by the editor <em>w</em>,
366<a href="qtable.html">QTable</a> calls this virtual function to copy the new values into the
367QTableItem.
368<p> If you reimplement <a href="#createEditor">createEditor</a>() and return something that is not
369a <a href="qlineedit.html">QLineEdit</a> you will need to reimplement this function.
370<p>
371
372<pre> void ComboItem::<a href="#setContentFromEditor">setContentFromEditor</a>( <a href="qwidget.html">QWidget</a> *w )
373 {
374 // the user changed the value of the combobox, so synchronize the
375 // value of the item (its text), with the value of the combobox
376 if ( w-&gt;<a href="qobject.html#inherits">inherits</a>( "QComboBox" ) )
377 <a href="#setText">setText</a>( ( (QComboBox*)w )-&gt;currentText() );
378 else
379 QTableItem::<a href="#setContentFromEditor">setContentFromEditor</a>( w );
380</pre>
381<p> <p>See also <a href="qtable.html#setCellContentFromEditor">QTable::setCellContentFromEditor</a>().
382
383<p>Example: <a href="statistics-example.html#x2787">table/statistics/statistics.cpp</a>.
384<h3 class=fn>void <a name="setEnabled"></a>QTableItem::setEnabled ( bool&nbsp;b )<tt> [virtual]</tt>
385</h3>
386If <em>b</em> is TRUE, the table item is enabled; if <em>b</em> is FALSE the
387table item is disabled.
388<p> A disabled item doesn't respond to user interaction.
389<p> <p>See also <a href="#isEnabled">isEnabled</a>().
390
391<h3 class=fn>void <a name="setPixmap"></a>QTableItem::setPixmap ( const&nbsp;<a href="qpixmap.html">QPixmap</a>&nbsp;&amp;&nbsp;p )<tt> [virtual]</tt>
392</h3>
393Sets pixmap <em>p</em> to be this item's pixmap.
394<p> Note that <a href="#setPixmap">setPixmap</a>() does not update the cell the table item
395belongs to. Use <a href="qtable.html#updateCell">QTable::updateCell</a>() to repaint the cell's
396contents.
397<p> For <a href="qcombotableitem.html">QComboTableItem</a>s and <a href="qchecktableitem.html">QCheckTableItem</a>s this function
398has no visible effect.
399<p> <p>See also <a href="qtable.html#setPixmap">QTable::setPixmap</a>(), <a href="#pixmap">pixmap</a>(), and <a href="#setText">setText</a>().
400
401<h3 class=fn>void <a name="setReplaceable"></a>QTableItem::setReplaceable ( bool&nbsp;b )<tt> [virtual]</tt>
402</h3>
403If <em>b</em> is TRUE it is acceptable to replace the contents of the
404cell with the contents of another QTableItem. If <em>b</em> is FALSE the
405contents of the cell may not be replaced by the contents of
406another table item. Table items that span more than one cell may
407not have their contents replaced by another table item.
408<p> (This differs from <a href="#EditType-enum">EditType</a> because EditType is concerned with
409whether the <em>user</em> is able to change the contents of a cell.)
410<p> <p>See also <a href="#isReplaceable">isReplaceable</a>().
411
412<h3 class=fn>void <a name="setRow"></a>QTableItem::setRow ( int&nbsp;r )<tt> [virtual]</tt>
413</h3>
414Sets row <em>r</em> as the table item's row. Usually you do not need to
415call this function.
416<p> If the cell spans multiple rows, this function sets the top row
417and retains the height of the multi-cell table item.
418<p> <p>See also <a href="#row">row</a>(), <a href="#setCol">setCol</a>(), and <a href="#rowSpan">rowSpan</a>().
419
420<h3 class=fn>void <a name="setSpan"></a>QTableItem::setSpan ( int&nbsp;rs, int&nbsp;cs )<tt> [virtual]</tt>
421</h3>
422Changes the extent of the QTableItem so that it spans multiple
423cells covering <em>rs</em> rows and <em>cs</em> columns. The top left cell is
424the original cell.
425<p> <b>Warning:</b> This function only works if the item has already been
426inserted into the table using e.g. <a href="qtable.html#setItem">QTable::setItem</a>(). This
427function also checks to make sure if <em>rs</em> and <em>cs</em> are within
428the bounds of the table and returns without changing the span if
429they are not. In addition swapping, inserting or removing rows and
430columns that cross QTableItems spanning more than one cell is not
431supported.
432<p> <p>See also <a href="#rowSpan">rowSpan</a>() and <a href="#colSpan">colSpan</a>().
433
434<h3 class=fn>void <a name="setText"></a>QTableItem::setText ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;str )<tt> [virtual]</tt>
435</h3>
436Changes the table item's text to <em>str</em>.
437<p> Note that <a href="#setText">setText</a>() does not update the cell the table item
438belongs to. Use <a href="qtable.html#updateCell">QTable::updateCell</a>() to repaint the cell's
439contents.
440<p> <p>See also <a href="qtable.html#setText">QTable::setText</a>(), <a href="#text">text</a>(), <a href="#setPixmap">setPixmap</a>(), and <a href="qtable.html#updateCell">QTable::updateCell</a>().
441
442<p>Example: <a href="statistics-example.html#x2788">table/statistics/statistics.cpp</a>.
443<h3 class=fn>void <a name="setWordWrap"></a>QTableItem::setWordWrap ( bool&nbsp;b )<tt> [virtual]</tt>
444</h3>
445If <em>b</em> is TRUE, the cell's text will be wrapped over multiple
446lines, when necessary, to fit the width of the cell; otherwise the
447text will be written as a single line.
448<p> <p>See also <a href="#wordWrap">wordWrap</a>(), <a href="qtable.html#adjustColumn">QTable::adjustColumn</a>(), and <a href="qtable.html#setColumnStretchable">QTable::setColumnStretchable</a>().
449
450<h3 class=fn><a href="qsize.html">QSize</a> <a name="sizeHint"></a>QTableItem::sizeHint () const<tt> [virtual]</tt>
451</h3>
452This virtual function returns the size a cell needs to show its
453entire content.
454<p> If you subclass QTableItem you will often need to reimplement this
455function.
456
457<h3 class=fn><a href="qtable.html">QTable</a>&nbsp;* <a name="table"></a>QTableItem::table () const
458</h3>
459
460<p> Returns the <a href="qtable.html">QTable</a> the table item belongs to.
461<p> <p>See also <a href="qtable.html#setItem">QTable::setItem</a>() and <a href="#QTableItem">QTableItem</a>().
462
463<h3 class=fn><a href="qstring.html">QString</a> <a name="text"></a>QTableItem::text () const<tt> [virtual]</tt>
464</h3>
465Returns the text of the table item or <a href="qstring.html#QString-null">QString::null</a> if there is no
466text.
467<p> To ensure that the current value of the editor is returned,
468<a href="#setContentFromEditor">setContentFromEditor</a>() is called:
469<ol type=1>
470<li> if the editMode() is <a href="#EditType-enum">Always</a>, or
471<li> if editMode() is <em>not</em> <a href="#EditType-enum">Always</a> but the editor of the cell is
472active and the editor is not a <a href="qlineedit.html">QLineEdit</a>.
473</ol>
474<p> This means that <a href="#text">text</a>() returns the original text value of the item
475if the editor is a line edit, until the user commits an edit (e.g.
476by pressing Enter or Tab) in which case the new text is returned.
477For other editors (e.g. a combobox) setContentFromEditor() is
478always called so the currently display value is the one returned.
479<p> <p>See also <a href="#setText">setText</a>() and <a href="#pixmap">pixmap</a>().
480
481<h3 class=fn>bool <a name="wordWrap"></a>QTableItem::wordWrap () const
482</h3>
483Returns TRUE if word wrap is enabled for the cell; otherwise
484returns FALSE.
485<p> <p>See also <a href="#setWordWrap">setWordWrap</a>().
486
487<!-- eof -->
488<hr><p>
489This file is part of the <a href="index.html">Qt toolkit</a>.
490Copyright &copy; 1995-2007
491<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
492<table width=100% cellspacing=0 border=0><tr>
493<td>Copyright &copy; 2007
494<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
495<td align=right><div align=right>Qt 3.3.8</div>
496</table></div></address></body>
497</html>
Note: See TracBrowser for help on using the repository browser.