[190] | 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"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { background: #ffffff; color: black; }
|
---|
| 12 | --></style>
|
---|
| 13 | </head>
|
---|
| 14 | <body>
|
---|
| 15 |
|
---|
| 16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
| 17 | <tr bgcolor="#E5E5E5">
|
---|
| 18 | <td valign=center>
|
---|
| 19 | <a href="index.html">
|
---|
| 20 | <font color="#004faf">Home</font></a>
|
---|
| 21 | | <a href="classes.html">
|
---|
| 22 | <font color="#004faf">All Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main Classes</font></a>
|
---|
| 25 | | <a href="annotated.html">
|
---|
| 26 | <font color="#004faf">Annotated</font></a>
|
---|
| 27 | | <a href="groups.html">
|
---|
| 28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
| 29 | | <a href="functions.html">
|
---|
| 30 | <font color="#004faf">Functions</font></a>
|
---|
| 31 | </td>
|
---|
| 32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>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 <<a href="qtable-h.html">qtable.h</a>></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 * table, EditType et )</li>
|
---|
| 44 | <li class=fn><a href="#QTableItem-2"><b>QTableItem</b></a> ( QTable * table, EditType et, const QString & text )</li>
|
---|
| 45 | <li class=fn><a href="#QTableItem-3"><b>QTableItem</b></a> ( QTable * table, EditType et, const QString & text, const QPixmap & 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 QPixmap & p )</li>
|
---|
| 50 | <li class=fn>virtual void <a href="#setText"><b>setText</b></a> ( const QString & 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 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 * w )</li>
|
---|
| 58 | <li class=fn>virtual void <a href="#setReplaceable"><b>setReplaceable</b></a> ( bool 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 rs, int 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 r )</li>
|
---|
| 66 | <li class=fn>virtual void <a href="#setCol"><b>setCol</b></a> ( int 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 * p, const QColorGroup & cg, const QRect & cr, bool selected )</li>
|
---|
| 70 | <li class=fn>virtual void <a href="#setEnabled"><b>setEnabled</b></a> ( bool 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 |
|
---|
| 77 | The 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
|
---|
| 82 | editing the contents of QTable cells. In situations where you need
|
---|
| 83 | to create very large tables you may prefer an alternative approach
|
---|
| 84 | to 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
|
---|
| 86 | pixmap. The table item also holds the cell's display size and how
|
---|
| 87 | the 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
|
---|
| 90 | you want comboboxes use <a href="qcombotableitem.html">QComboTableItem</a>. The <a href="#EditType-enum">EditType</a> (set
|
---|
| 91 | in the constructor) determines whether the cell's contents may be
|
---|
| 92 | edited.
|
---|
| 93 | <p> If a pixmap is specified it is displayed to the left of any text.
|
---|
| 94 | You can change the text or pixmap with <a href="#setText">setText</a>() and <a href="#setPixmap">setPixmap</a>()
|
---|
| 95 | respectively. 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
|
---|
| 97 | this returns the table item's <a href="#text">text</a>(). Reimplement key() to
|
---|
| 98 | customize 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
|
---|
| 100 | you insert an item into a cell that already contains a table item
|
---|
| 101 | the original item will be deleted.
|
---|
| 102 | <p> Example:
|
---|
| 103 | <pre>
|
---|
| 104 | for ( int row = 0; row < table->numRows(); row++ ) {
|
---|
| 105 | for ( int col = 0; col < table->numCols(); col++ ) {
|
---|
| 106 | table->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
|
---|
| 113 | a different table, using <a href="qtable.html#takeItem">QTable::takeItem</a>() and QTable::setItem()
|
---|
| 114 | but see also <a href="qtable.html#swapCells">QTable::swapCells</a>().
|
---|
| 115 | <p> Table items can be deleted with delete in the standard way; the
|
---|
| 116 | table and cell will be updated accordingly.
|
---|
| 117 | <p> Note, that if you have a table item that is not currently in a table
|
---|
| 118 | then anything you do to that item other than insert it into a table
|
---|
| 119 | will result in undefined behaviour.
|
---|
| 120 | <p> Reimplement <a href="#createEditor">createEditor</a>() and <a href="#setContentFromEditor">setContentFromEditor</a>() if you want
|
---|
| 121 | to use your own widget instead of a <a href="qlineedit.html">QLineEdit</a> for editing cell
|
---|
| 122 | contents. Reimplement <a href="#paint">paint</a>() if you want to display custom
|
---|
| 123 | content.
|
---|
| 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
|
---|
| 126 | table as normal. Therefore, if the widget returned by createEditor()
|
---|
| 127 | does not itself accept the keyboard focus, it is necessary to
|
---|
| 128 | nominate 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
|
---|
| 130 | accept 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>()->viewport() );
|
---|
| 135 | hbox-><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
|
---|
| 142 | during the lifetime of a <a href="qtable.html">QTable</a>. Therefore, if you create your
|
---|
| 143 | own subclass of QTableItem, and you want to ensure that
|
---|
| 144 | this does not happen, you must call <a href="#setReplaceable">setReplaceable</a>(FALSE)
|
---|
| 145 | in 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>
|
---|
| 154 | This enum is used to define whether a cell is editable or
|
---|
| 155 | read-only (in conjunction with other settings), and how the cell
|
---|
| 156 | should be displayed.
|
---|
| 157 | <ul>
|
---|
| 158 | <li><tt>QTableItem::Always</tt> -
|
---|
| 159 | The 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
|
---|
| 162 | has implications for the alignment of the content: the default
|
---|
| 163 | editor aligns everything (even numbers) to the left whilst
|
---|
| 164 | numerical 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
|
---|
| 166 | reimplement createEditor() for these items.
|
---|
| 167 | <ul>
|
---|
| 168 | <li><tt>QTableItem::WhenCurrent</tt> -
|
---|
| 169 | The 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> -
|
---|
| 172 | The cell <em>looks</em> editable only when the user types in it or
|
---|
| 173 | double-clicks it. It resembles the <a href="#EditType-enum">WhenCurrent</a> functionality
|
---|
| 174 | but is, perhaps, nicer.
|
---|
| 175 | </ul><p> The <a href="#EditType-enum">OnTyping</a> edit type is the default when QTableItem objects
|
---|
| 176 | are 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
|
---|
| 181 | FALSE for its row, <a href="qtable.html#isColumnReadOnly">QTable::isColumnReadOnly</a>() is FALSE for its
|
---|
| 182 | column, and <a href="qtable.html#isReadOnly">QTable::isReadOnly</a>() is FALSE.
|
---|
| 183 | <p> QComboTableItems have an isEditable() property. This property is
|
---|
| 184 | used to indicate whether the user may enter their own text or are
|
---|
| 185 | restricted to choosing one of the choices in the list.
|
---|
| 186 | QComboTableItems may be interacted with only if they are editable
|
---|
| 187 | in 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> * table, <a href="qtableitem.html#EditType-enum">EditType</a> et )
|
---|
| 191 | </h3>
|
---|
| 192 | Creates a table item that is a child of table <em>table</em> with no
|
---|
| 193 | text. 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
|
---|
| 195 | word-wrap and will occupy a single cell. Insert the table item
|
---|
| 196 | into 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
|
---|
| 198 | should 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> * table, <a href="qtableitem.html#EditType-enum">EditType</a> et, const <a href="qstring.html">QString</a> & text )
|
---|
| 201 | </h3>
|
---|
| 202 | Creates 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
|
---|
| 205 | word-wrap and will occupy a single cell. Insert the table item
|
---|
| 206 | into 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
|
---|
| 208 | should 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> * table, <a href="qtableitem.html#EditType-enum">EditType</a> et, const <a href="qstring.html">QString</a> & text, const <a href="qpixmap.html">QPixmap</a> & p )
|
---|
| 211 | </h3>
|
---|
| 212 | Creates 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
|
---|
| 215 | will use a <a href="qlineedit.html">QLineEdit</a> for editing the text, will not word-wrap and
|
---|
| 216 | will 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
|
---|
| 219 | should 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>
|
---|
| 223 | The destructor deletes this item and frees all allocated
|
---|
| 224 | resources.
|
---|
| 225 | <p> If the table item is in a table (i.e. was inserted with
|
---|
| 226 | setItem()), it will be removed from the table and the cell it
|
---|
| 227 | occupied.
|
---|
| 228 |
|
---|
| 229 | <h3 class=fn>int <a name="alignment"></a>QTableItem::alignment () const<tt> [virtual]</tt>
|
---|
| 230 | </h3>
|
---|
| 231 | The alignment function returns how the text contents of the cell
|
---|
| 232 | are aligned when drawn. The default implementation aligns numbers
|
---|
| 233 | to 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>
|
---|
| 238 | Returns the column where the table item is located. If the cell
|
---|
| 239 | spans multiple columns, this function returns the left-most
|
---|
| 240 | column.
|
---|
| 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>
|
---|
| 246 | Returns 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> * <a name="createEditor"></a>QTableItem::createEditor () const<tt> [virtual]</tt>
|
---|
| 250 | </h3>
|
---|
| 251 | This virtual function creates an editor which the user can
|
---|
| 252 | interact with to edit the cell's contents. The default
|
---|
| 253 | implementation 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
|
---|
| 258 | reimplement <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 )->cb = new <a href="qcombobox.html">QComboBox</a>( <a href="#table">table</a>()->viewport() );
|
---|
| 266 | QObject::<a href="qobject.html#connect">connect</a>( cb, SIGNAL( activated( int ) ), table(), SLOT( doValueChanged() ) );
|
---|
| 267 | cb->insertItem( "Yes" );
|
---|
| 268 | cb->insertItem( "No" );
|
---|
| 269 | // and initialize it
|
---|
| 270 | cb->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>
|
---|
| 278 | Returns 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>
|
---|
| 284 | Returns 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>
|
---|
| 289 | This function returns whether the contents of the cell may be
|
---|
| 290 | replaced with the contents of another table item. Regardless of
|
---|
| 291 | this setting, table items that span more than one cell may not
|
---|
| 292 | have their contents replaced by another table item.
|
---|
| 293 | <p> (This differs from <a href="#EditType-enum">EditType</a> because EditType is concerned with
|
---|
| 294 | whether 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>
|
---|
| 299 | This virtual function returns the key that should be used for
|
---|
| 300 | sorting. The default implementation returns the <a href="#text">text</a>() of the
|
---|
| 301 | relevant 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> * p, const <a href="qcolorgroup.html">QColorGroup</a> & cg, const <a href="qrect.html">QRect</a> & cr, bool selected )<tt> [virtual]</tt>
|
---|
| 305 | </h3>
|
---|
| 306 | This virtual function is used to paint the contents of an item
|
---|
| 307 | using the painter <em>p</em> in the rectangular area <em>cr</em> using the
|
---|
| 308 | color group <em>cg</em>.
|
---|
| 309 | <p> If <em>selected</em> is TRUE the cell is displayed in a way that
|
---|
| 310 | indicates that it is highlighted.
|
---|
| 311 | <p> You don't usually need to use this function but if you want to
|
---|
| 312 | draw 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
|
---|
| 314 | is 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
|
---|
| 316 | maximum efficiency. If you want clipping, use
|
---|
| 317 | <p> <pre>
|
---|
| 318 | p->setClipRect( <a href="#table">table</a>()->cellRect(row, col), QPainter::ClipPainter );
|
---|
| 319 | //... your drawing code
|
---|
| 320 | p->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>
|
---|
| 327 | Returns the table item's pixmap or a null pixmap if no pixmap has
|
---|
| 328 | been 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>
|
---|
| 333 | Returns the row where the table item is located. If the cell spans
|
---|
| 334 | multiple 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>
|
---|
| 340 | Returns 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>
|
---|
| 345 | Returns the Run Time Type Identification value for this table item
|
---|
| 346 | which for QTableItems is 0.
|
---|
| 347 | <p> When you create subclasses based on QTableItem make sure that each
|
---|
| 348 | subclass returns a unique <a href="#rtti">rtti</a>() value. It is advisable to use
|
---|
| 349 | values greater than 1000, preferably large random numbers, to
|
---|
| 350 | allow 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 c )<tt> [virtual]</tt>
|
---|
| 355 | </h3>
|
---|
| 356 | Sets column <em>c</em> as the table item's column. Usually you will not
|
---|
| 357 | need to call this function.
|
---|
| 358 | <p> If the cell spans multiple columns, this function sets the
|
---|
| 359 | left-most column and retains the width of the multi-cell table
|
---|
| 360 | item.
|
---|
| 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> * w )<tt> [virtual]</tt>
|
---|
| 364 | </h3>
|
---|
| 365 | Whenever 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
|
---|
| 367 | QTableItem.
|
---|
| 368 | <p> If you reimplement <a href="#createEditor">createEditor</a>() and return something that is not
|
---|
| 369 | a <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-><a href="qobject.html#inherits">inherits</a>( "QComboBox" ) )
|
---|
| 377 | <a href="#setText">setText</a>( ( (QComboBox*)w )->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 b )<tt> [virtual]</tt>
|
---|
| 385 | </h3>
|
---|
| 386 | If <em>b</em> is TRUE, the table item is enabled; if <em>b</em> is FALSE the
|
---|
| 387 | table 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 <a href="qpixmap.html">QPixmap</a> & p )<tt> [virtual]</tt>
|
---|
| 392 | </h3>
|
---|
| 393 | Sets 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
|
---|
| 395 | belongs to. Use <a href="qtable.html#updateCell">QTable::updateCell</a>() to repaint the cell's
|
---|
| 396 | contents.
|
---|
| 397 | <p> For <a href="qcombotableitem.html">QComboTableItem</a>s and <a href="qchecktableitem.html">QCheckTableItem</a>s this function
|
---|
| 398 | has 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 b )<tt> [virtual]</tt>
|
---|
| 402 | </h3>
|
---|
| 403 | If <em>b</em> is TRUE it is acceptable to replace the contents of the
|
---|
| 404 | cell with the contents of another QTableItem. If <em>b</em> is FALSE the
|
---|
| 405 | contents of the cell may not be replaced by the contents of
|
---|
| 406 | another table item. Table items that span more than one cell may
|
---|
| 407 | not have their contents replaced by another table item.
|
---|
| 408 | <p> (This differs from <a href="#EditType-enum">EditType</a> because EditType is concerned with
|
---|
| 409 | whether 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 r )<tt> [virtual]</tt>
|
---|
| 413 | </h3>
|
---|
| 414 | Sets row <em>r</em> as the table item's row. Usually you do not need to
|
---|
| 415 | call this function.
|
---|
| 416 | <p> If the cell spans multiple rows, this function sets the top row
|
---|
| 417 | and 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 rs, int cs )<tt> [virtual]</tt>
|
---|
| 421 | </h3>
|
---|
| 422 | Changes the extent of the QTableItem so that it spans multiple
|
---|
| 423 | cells covering <em>rs</em> rows and <em>cs</em> columns. The top left cell is
|
---|
| 424 | the original cell.
|
---|
| 425 | <p> <b>Warning:</b> This function only works if the item has already been
|
---|
| 426 | inserted into the table using e.g. <a href="qtable.html#setItem">QTable::setItem</a>(). This
|
---|
| 427 | function also checks to make sure if <em>rs</em> and <em>cs</em> are within
|
---|
| 428 | the bounds of the table and returns without changing the span if
|
---|
| 429 | they are not. In addition swapping, inserting or removing rows and
|
---|
| 430 | columns that cross QTableItems spanning more than one cell is not
|
---|
| 431 | supported.
|
---|
| 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 <a href="qstring.html">QString</a> & str )<tt> [virtual]</tt>
|
---|
| 435 | </h3>
|
---|
| 436 | Changes 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
|
---|
| 438 | belongs to. Use <a href="qtable.html#updateCell">QTable::updateCell</a>() to repaint the cell's
|
---|
| 439 | contents.
|
---|
| 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 b )<tt> [virtual]</tt>
|
---|
| 444 | </h3>
|
---|
| 445 | If <em>b</em> is TRUE, the cell's text will be wrapped over multiple
|
---|
| 446 | lines, when necessary, to fit the width of the cell; otherwise the
|
---|
| 447 | text 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>
|
---|
| 452 | This virtual function returns the size a cell needs to show its
|
---|
| 453 | entire content.
|
---|
| 454 | <p> If you subclass QTableItem you will often need to reimplement this
|
---|
| 455 | function.
|
---|
| 456 |
|
---|
| 457 | <h3 class=fn><a href="qtable.html">QTable</a> * <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>
|
---|
| 465 | Returns the text of the table item or <a href="qstring.html#QString-null">QString::null</a> if there is no
|
---|
| 466 | text.
|
---|
| 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
|
---|
| 472 | active 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
|
---|
| 475 | if the editor is a line edit, until the user commits an edit (e.g.
|
---|
| 476 | by pressing Enter or Tab) in which case the new text is returned.
|
---|
| 477 | For other editors (e.g. a combobox) setContentFromEditor() is
|
---|
| 478 | always 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>
|
---|
| 483 | Returns TRUE if word wrap is enabled for the cell; otherwise
|
---|
| 484 | returns FALSE.
|
---|
| 485 | <p> <p>See also <a href="#setWordWrap">setWordWrap</a>().
|
---|
| 486 |
|
---|
| 487 | <!-- eof -->
|
---|
| 488 | <hr><p>
|
---|
| 489 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 490 | Copyright © 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 © 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>
|
---|