1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QTableWidgetItem Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QTableWidgetItem Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QTableWidgetItem class provides an item for use with the <a href="qtablewidget.html">QTableWidget</a> class. <a href="#details">More...</a></p>
<h3>Methods</h3><ul><li><div class="fn" /><b><a href="qtablewidgetitem.html#QTableWidgetItem">__init__</a></b> (<i>self</i>, int <i>type</i> = QTableWidgetItem.Type)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#QTableWidgetItem-2">__init__</a></b> (<i>self</i>, QString <i>text</i>, int <i>type</i> = QTableWidgetItem.Type)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#QTableWidgetItem-3">__init__</a></b> (<i>self</i>, QTableWidgetItem <i>other</i>)</li><li><div class="fn" />QColor <b><a href="qtablewidgetitem.html#backgroundColor">backgroundColor</a></b> (<i>self</i>)</li><li><div class="fn" />Qt.CheckState <b><a href="qtablewidgetitem.html#checkState">checkState</a></b> (<i>self</i>)</li><li><div class="fn" />QTableWidgetItem <b><a href="qtablewidgetitem.html#clone">clone</a></b> (<i>self</i>)</li><li><div class="fn" />QVariant <b><a href="qtablewidgetitem.html#data">data</a></b> (<i>self</i>, int <i>role</i>)</li><li><div class="fn" />Qt.ItemFlags <b><a href="qtablewidgetitem.html#flags">flags</a></b> (<i>self</i>)</li><li><div class="fn" />QFont <b><a href="qtablewidgetitem.html#font">font</a></b> (<i>self</i>)</li><li><div class="fn" />QIcon <b><a href="qtablewidgetitem.html#icon">icon</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#read">read</a></b> (<i>self</i>, QDataStream <i>in</i>)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#setBackgroundColor">setBackgroundColor</a></b> (<i>self</i>, QColor <i>color</i>)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#setCheckState">setCheckState</a></b> (<i>self</i>, Qt.CheckState <i>state</i>)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#setData">setData</a></b> (<i>self</i>, int <i>role</i>, QVariant <i>value</i>)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#setFlags">setFlags</a></b> (<i>self</i>, Qt.ItemFlags <i>aflags</i>)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#setFont">setFont</a></b> (<i>self</i>, QFont <i>afont</i>)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#setIcon">setIcon</a></b> (<i>self</i>, QIcon <i>aicon</i>)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#setSizeHint">setSizeHint</a></b> (<i>self</i>, QSize <i>size</i>)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#setStatusTip">setStatusTip</a></b> (<i>self</i>, QString <i>astatusTip</i>)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#setText">setText</a></b> (<i>self</i>, QString <i>atext</i>)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#setTextAlignment">setTextAlignment</a></b> (<i>self</i>, int <i>alignment</i>)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#setTextColor">setTextColor</a></b> (<i>self</i>, QColor <i>color</i>)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#setToolTip">setToolTip</a></b> (<i>self</i>, QString <i>atoolTip</i>)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#setWhatsThis">setWhatsThis</a></b> (<i>self</i>, QString <i>awhatsThis</i>)</li><li><div class="fn" />QSize <b><a href="qtablewidgetitem.html#sizeHint">sizeHint</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qtablewidgetitem.html#statusTip">statusTip</a></b> (<i>self</i>)</li><li><div class="fn" />QTableWidget <b><a href="qtablewidgetitem.html#tableWidget">tableWidget</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qtablewidgetitem.html#text">text</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtablewidgetitem.html#textAlignment">textAlignment</a></b> (<i>self</i>)</li><li><div class="fn" />QColor <b><a href="qtablewidgetitem.html#textColor">textColor</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qtablewidgetitem.html#toolTip">toolTip</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtablewidgetitem.html#type">type</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qtablewidgetitem.html#whatsThis">whatsThis</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtablewidgetitem.html#write">write</a></b> (<i>self</i>, QDataStream <i>out</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qtablewidgetitem.html#__lt__">__lt__</a></b> (<i>self</i>, QTableWidgetItem <i>other</i>)</li></ul><h3>Static Members</h3><ul><li><div class="fn" />int <b><a href="qtablewidgetitem.html#Type-var">Type</a></b></li><li><div class="fn" />int <b><a href="qtablewidgetitem.html#UserType-var">UserType</a></b></li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QTableWidgetItem class provides an item for use with the <a href="qtablewidget.html">QTableWidget</a> class.</p>
<p>Table items are used to hold pieces of information for table widgets. Items usually contain text, icons, or checkboxes</p>
<p>The QTableWidgetItem class is a convenience class that replaces the <tt>QTableItem</tt> class in Qt 3. It provides an item for use with the <a href="qtablewidget.html">QTableWidget</a> class.</p>
<p>Top-level items are constructed without a parent then inserted at the position specified by a pair of row and column numbers:</p>
<pre>
QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").arg(
pow(row, column+1)));
tableWidget->setItem(row, column, newItem);
</pre>
<p>Each item can have its own background color which is set with the <a href="qtablewidgetitem.html#setBackgroundColor">setBackgroundColor</a>() function. The current background color can be found with <a href="qtablewidgetitem.html#backgroundColor">backgroundColor</a>(). The text label for each item can be rendered with its own font and text color. These are specified with the <a href="qtablewidgetitem.html#setFont">setFont</a>() and <a href="qtablewidgetitem.html#setTextColor">setTextColor</a>() functions, and read with <a href="qtablewidgetitem.html#font">font</a>() and <a href="qtablewidgetitem.html#textColor">textColor</a>().</p>
<p>By default, items are enabled, editable, selectable, checkable, and can be used both as the source of a drag and drop operation and as a drop target. Each item's flags can be changed by calling <a href="qtablewidgetitem.html#setFlags">setFlags</a>() with the appropriate value (see <a href="qt.html#ItemFlag-enum">Qt.ItemFlags</a>). Checkable items can be checked and unchecked with the setChecked() function. The corresponding checked() function indicates whether the item is currently checked.</p>
<p>See also <a href="qtablewidget.html">QTableWidget</a>, <a href="model-view-programming.html">Model/View Programming</a>, <a href="qlistwidgetitem.html">QListWidgetItem</a>, and <a href="qtreewidgetitem.html">QTreeWidgetItem</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QTableWidgetItem" />QTableWidgetItem.__init__ (<i>self</i>, int <i>type</i> = QTableWidgetItem.Type)</h3><p>Constructs a table item of the specified <i>type</i> that does not belong to any table.</p>
<p>See also <a href="qtablewidgetitem.html#type">type</a>().</p>
<h3 class="fn"><a name="QTableWidgetItem-2" />QTableWidgetItem.__init__ (<i>self</i>, <a href="qstring.html">QString</a> <i>text</i>, int <i>type</i> = QTableWidgetItem.Type)</h3><p>Constructs a table item with the given <i>text</i>.</p>
<p>See also <a href="qtablewidgetitem.html#type">type</a>().</p>
<h3 class="fn"><a name="QTableWidgetItem-3" />QTableWidgetItem.__init__ (<i>self</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>other</i>)</h3><p>Constructs a copy of <i>other</i>. Note that <a href="qtablewidgetitem.html#type">type</a>() and <a href="qtablewidgetitem.html#tableWidget">tableWidget</a>() are not copied.</p>
<p>This function is useful when reimplementing <a href="qtablewidgetitem.html#clone">clone</a>().</p>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qtablewidgetitem.html#data">data</a>() and <a href="qtablewidgetitem.html#flags">flags</a>().</p>
<h3 class="fn"><a name="backgroundColor" /><a href="qcolor.html">QColor</a> QTableWidgetItem.backgroundColor (<i>self</i>)</h3><p>Returns the color used to render the item's background.</p>
<p>See also <a href="qtablewidgetitem.html#textColor">textColor</a>() and <a href="qtablewidgetitem.html#setBackgroundColor">setBackgroundColor</a>().</p>
<h3 class="fn"><a name="checkState" /><a href="qt.html#CheckState-enum">Qt.CheckState</a> QTableWidgetItem.checkState (<i>self</i>)</h3><p>Returns the checked state of the table item.</p>
<p>See also <a href="qtablewidgetitem.html#setCheckState">setCheckState</a>() and <a href="qtablewidgetitem.html#flags">flags</a>().</p>
<h3 class="fn"><a name="clone" /><a href="qtablewidgetitem.html">QTableWidgetItem</a> QTableWidgetItem.clone (<i>self</i>)</h3><p>Creates a copy of the item.</p>
<h3 class="fn"><a name="data" /><a href="qvariant.html">QVariant</a> QTableWidgetItem.data (<i>self</i>, int <i>role</i>)</h3><p>Returns the item's data for the given <i>role</i>.</p>
<p>See also <a href="qtablewidgetitem.html#setData">setData</a>().</p>
<h3 class="fn"><a name="flags" /><a href="qt-itemflags.html">Qt.ItemFlags</a> QTableWidgetItem.flags (<i>self</i>)</h3><p>Returns the flags used to describe the item. These determine whether the item can be checked, edited, and selected.</p>
<p>See also <a href="qtablewidgetitem.html#setFlags">setFlags</a>().</p>
<h3 class="fn"><a name="font" /><a href="qfont.html">QFont</a> QTableWidgetItem.font (<i>self</i>)</h3><p>Returns the font used to render the item's text.</p>
<p>See also <a href="qtablewidgetitem.html#setFont">setFont</a>().</p>
<h3 class="fn"><a name="icon" /><a href="qicon.html">QIcon</a> QTableWidgetItem.icon (<i>self</i>)</h3><p>Returns the item's icon.</p>
<p>See also <a href="qtablewidgetitem.html#setIcon">setIcon</a>() and <a href="qabstractitemview.html#iconSize-prop">iconSize</a>.</p>
<h3 class="fn"><a name="read" />QTableWidgetItem.read (<i>self</i>, <a href="qdatastream.html">QDataStream</a> <i>in</i>)</h3><p>Reads the item from stream <i>in</i>.</p>
<p>See also <a href="qtablewidgetitem.html#write">write</a>().</p>
<h3 class="fn"><a name="setBackgroundColor" />QTableWidgetItem.setBackgroundColor (<i>self</i>, <a href="qcolor.html">QColor</a> <i>color</i>)</h3><p>Sets the item's background color to the specified <i>color</i>.</p>
<p>See also <a href="qtablewidgetitem.html#backgroundColor">backgroundColor</a>() and <a href="qtablewidgetitem.html#setTextColor">setTextColor</a>().</p>
<h3 class="fn"><a name="setCheckState" />QTableWidgetItem.setCheckState (<i>self</i>, <a href="qt.html#CheckState-enum">Qt.CheckState</a> <i>state</i>)</h3><p>Sets the check state of the table item to be <i>state</i>.</p>
<p>See also <a href="qtablewidgetitem.html#checkState">checkState</a>().</p>
<h3 class="fn"><a name="setData" />QTableWidgetItem.setData (<i>self</i>, int <i>role</i>, <a href="qvariant.html">QVariant</a> <i>value</i>)</h3><p>Sets the item's data for the given <i>role</i> to the specified <i>value</i>.</p>
<p>See also <a href="qt.html#ItemDataRole-enum">Qt.ItemDataRole</a> and <a href="qtablewidgetitem.html#data">data</a>().</p>
<h3 class="fn"><a name="setFlags" />QTableWidgetItem.setFlags (<i>self</i>, <a href="qt-itemflags.html">Qt.ItemFlags</a> <i>aflags</i>)</h3><p>Sets the flags for the item to the given <i>flags</i>. These determine whether the item can be selected or modified.</p>
<p>See also <a href="qtablewidgetitem.html#flags">flags</a>().</p>
<h3 class="fn"><a name="setFont" />QTableWidgetItem.setFont (<i>self</i>, <a href="qfont.html">QFont</a> <i>afont</i>)</h3><p>Sets the font used to display the item's text to the given <i>font</i>.</p>
<p>See also <a href="qtablewidgetitem.html#font">font</a>(), <a href="qtablewidgetitem.html#setText">setText</a>(), and <a href="qtablewidgetitem.html#setTextColor">setTextColor</a>().</p>
<h3 class="fn"><a name="setIcon" />QTableWidgetItem.setIcon (<i>self</i>, <a href="qicon.html">QIcon</a> <i>aicon</i>)</h3><p>Sets the item's icon to the <i>icon</i> specified.</p>
<p>See also <a href="qtablewidgetitem.html#icon">icon</a>(), <a href="qtablewidgetitem.html#setText">setText</a>(), and <a href="qabstractitemview.html#iconSize-prop">iconSize</a>.</p>
<h3 class="fn"><a name="setSizeHint" />QTableWidgetItem.setSizeHint (<i>self</i>, <a href="qsize.html">QSize</a> <i>size</i>)</h3><p>Sets the size hint for the table item to be <i>size</i>. If no size hint is set, the item delegate will compute the size hint based on the item data.</p>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qtablewidgetitem.html#sizeHint">sizeHint</a>().</p>
<h3 class="fn"><a name="setStatusTip" />QTableWidgetItem.setStatusTip (<i>self</i>, <a href="qstring.html">QString</a> <i>astatusTip</i>)</h3><p>Sets the item's status tip to the string specified by <i>statusTip</i>.</p>
<p>See also <a href="qtablewidgetitem.html#statusTip">statusTip</a>(), <a href="qtablewidgetitem.html#setToolTip">setToolTip</a>(), and <a href="qtablewidgetitem.html#setWhatsThis">setWhatsThis</a>().</p>
<h3 class="fn"><a name="setText" />QTableWidgetItem.setText (<i>self</i>, <a href="qstring.html">QString</a> <i>atext</i>)</h3><p>Sets the item's text to the <i>text</i> specified.</p>
<p>See also <a href="qtablewidgetitem.html#text">text</a>(), <a href="qtablewidgetitem.html#setFont">setFont</a>(), and <a href="qtablewidgetitem.html#setTextColor">setTextColor</a>().</p>
<h3 class="fn"><a name="setTextAlignment" />QTableWidgetItem.setTextAlignment (<i>self</i>, int <i>alignment</i>)</h3><p>Sets the text alignment for the item's text to the <i>alignment</i> specified.</p>
<p>See also <a href="qtablewidgetitem.html#textAlignment">textAlignment</a>() and <a href="qt.html#AlignmentFlag-enum">Qt.Alignment</a>.</p>
<h3 class="fn"><a name="setTextColor" />QTableWidgetItem.setTextColor (<i>self</i>, <a href="qcolor.html">QColor</a> <i>color</i>)</h3><p>Sets the color used to display the item's text to the given <i>color</i>.</p>
<p>See also <a href="qtablewidgetitem.html#textColor">textColor</a>(), <a href="qtablewidgetitem.html#setFont">setFont</a>(), and <a href="qtablewidgetitem.html#setText">setText</a>().</p>
<h3 class="fn"><a name="setToolTip" />QTableWidgetItem.setToolTip (<i>self</i>, <a href="qstring.html">QString</a> <i>atoolTip</i>)</h3><p>Sets the item's tooltip to the string specified by <i>toolTip</i>.</p>
<p>See also <a href="qtablewidgetitem.html#toolTip">toolTip</a>(), <a href="qtablewidgetitem.html#setStatusTip">setStatusTip</a>(), and <a href="qtablewidgetitem.html#setWhatsThis">setWhatsThis</a>().</p>
<h3 class="fn"><a name="setWhatsThis" />QTableWidgetItem.setWhatsThis (<i>self</i>, <a href="qstring.html">QString</a> <i>awhatsThis</i>)</h3><p>Sets the item's "What's This?" help to the string specified by <i>whatsThis</i>.</p>
<p>See also <a href="qtablewidgetitem.html#whatsThis">whatsThis</a>(), <a href="qtablewidgetitem.html#setStatusTip">setStatusTip</a>(), and <a href="qtablewidgetitem.html#setToolTip">setToolTip</a>().</p>
<h3 class="fn"><a name="sizeHint" /><a href="qsize.html">QSize</a> QTableWidgetItem.sizeHint (<i>self</i>)</h3><p>Returns the size hint set for the table item.</p>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qtablewidgetitem.html#setSizeHint">setSizeHint</a>().</p>
<h3 class="fn"><a name="statusTip" /><a href="qstring.html">QString</a> QTableWidgetItem.statusTip (<i>self</i>)</h3><p>Returns the item's status tip.</p>
<p>See also <a href="qtablewidgetitem.html#setStatusTip">setStatusTip</a>().</p>
<h3 class="fn"><a name="tableWidget" /><a href="qtablewidget.html">QTableWidget</a> QTableWidgetItem.tableWidget (<i>self</i>)</h3><p>Returns the table widget that contains the item.</p>
<h3 class="fn"><a name="text" /><a href="qstring.html">QString</a> QTableWidgetItem.text (<i>self</i>)</h3><p>Returns the item's text.</p>
<p>See also <a href="qtablewidgetitem.html#setText">setText</a>().</p>
<h3 class="fn"><a name="textAlignment" />int QTableWidgetItem.textAlignment (<i>self</i>)</h3><p>Returns the text alignment for the item's text.</p>
<p>See also <a href="qtablewidgetitem.html#setTextAlignment">setTextAlignment</a>() and <a href="qt.html#AlignmentFlag-enum">Qt.Alignment</a>.</p>
<h3 class="fn"><a name="textColor" /><a href="qcolor.html">QColor</a> QTableWidgetItem.textColor (<i>self</i>)</h3><p>Returns the color used to render the item's text.</p>
<p>See also <a href="qtablewidgetitem.html#backgroundColor">backgroundColor</a>() and <a href="qtablewidgetitem.html#setTextColor">setTextColor</a>().</p>
<h3 class="fn"><a name="toolTip" /><a href="qstring.html">QString</a> QTableWidgetItem.toolTip (<i>self</i>)</h3><p>Returns the item's tooltip.</p>
<p>See also <a href="qtablewidgetitem.html#setToolTip">setToolTip</a>().</p>
<h3 class="fn"><a name="type" />int QTableWidgetItem.type (<i>self</i>)</h3><p>Returns the type passed to the <a href="qtablewidgetitem.html">QTableWidgetItem</a> constructor.</p>
<h3 class="fn"><a name="whatsThis" /><a href="qstring.html">QString</a> QTableWidgetItem.whatsThis (<i>self</i>)</h3><p>Returns the item's "What's This?" help.</p>
<p>See also <a href="qtablewidgetitem.html#setWhatsThis">setWhatsThis</a>().</p>
<h3 class="fn"><a name="write" />QTableWidgetItem.write (<i>self</i>, <a href="qdatastream.html">QDataStream</a> <i>out</i>)</h3><p>Writes the item to stream <i>out</i>.</p>
<p>See also <a href="qtablewidgetitem.html#read">read</a>().</p>
<h3 class="fn"><a name="__lt__" />bool QTableWidgetItem.__lt__ (<i>self</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>other</i>)</h3><hr /><h2>Member Documentation</h2><h3 class="fn"><a name="Type-var" />int Type</h3><p>This member should be treated as a constant.</p><p>The default type for table widget items.</p>
<p>See also <a href="qtablewidgetitem.html#UserType-var">UserType</a> and <a href="qtablewidgetitem.html#type">type</a>().</p>
<h3 class="fn"><a name="UserType-var" />int UserType</h3><p>This member should be treated as a constant.</p><p>The minimum value for custom types. Values below UserType are reserved by Qt.</p>
<p>See also <a href="qtablewidgetitem.html#Type-var">Type</a> and <a href="qtablewidgetitem.html#type">type</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt 4.0.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.trolltech.com">Trolltech AS</a> 2006</td><td align="right" width="25%">Qt 4.1.4</td></tr></table></div></address></body></html>
|