<?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>QTableWidget 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="index.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">QTableWidget Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QTableWidget class provides an item-based table view with a default model. <a href="#details">More...</a></p> <p>Inherits <a href="qtableview.html">QTableView</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qtablewidget.html#QTableWidget">__init__</a></b> (<i>self</i>, QWidget <i>parent</i> = None)</li><li><div class="fn" /><b><a href="qtablewidget.html#QTableWidget-2">__init__</a></b> (<i>self</i>, int <i>rows</i>, int <i>columns</i>, QWidget <i>parent</i> = None)</li><li><div class="fn" />QWidget <b><a href="qtablewidget.html#cellWidget">cellWidget</a></b> (<i>self</i>, int <i>row</i>, int <i>column</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#clear">clear</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#clearContents">clearContents</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#closePersistentEditor">closePersistentEditor</a></b> (<i>self</i>, QTableWidgetItem <i>item</i>)</li><li><div class="fn" />int <b><a href="qtablewidget.html#column">column</a></b> (<i>self</i>, QTableWidgetItem <i>item</i>)</li><li><div class="fn" />int <b><a href="qtablewidget.html#columnCount">columnCount</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtablewidget.html#currentColumn">currentColumn</a></b> (<i>self</i>)</li><li><div class="fn" />QTableWidgetItem <b><a href="qtablewidget.html#currentItem">currentItem</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qtablewidget.html#currentRow">currentRow</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#dropEvent">dropEvent</a></b> (<i>self</i>, QDropEvent <i>event</i>)</li><li><div class="fn" />bool <b><a href="qtablewidget.html#dropMimeData">dropMimeData</a></b> (<i>self</i>, int <i>row</i>, int <i>column</i>, QMimeData <i>data</i>, Qt.DropAction <i>action</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#editItem">editItem</a></b> (<i>self</i>, QTableWidgetItem <i>item</i>)</li><li><div class="fn" />bool <b><a href="qtablewidget.html#event">event</a></b> (<i>self</i>, QEvent <i>e</i>)</li><li><div class="fn" />list-of-QTableWidgetItem <b><a href="qtablewidget.html#findItems">findItems</a></b> (<i>self</i>, QString <i>text</i>, Qt.MatchFlags <i>flags</i>)</li><li><div class="fn" />QTableWidgetItem <b><a href="qtablewidget.html#horizontalHeaderItem">horizontalHeaderItem</a></b> (<i>self</i>, int <i>column</i>)</li><li><div class="fn" />QModelIndex <b><a href="qtablewidget.html#indexFromItem">indexFromItem</a></b> (<i>self</i>, QTableWidgetItem <i>item</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#insertColumn">insertColumn</a></b> (<i>self</i>, int <i>column</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#insertRow">insertRow</a></b> (<i>self</i>, int <i>row</i>)</li><li><div class="fn" />bool <b><a href="qtablewidget.html#isItemSelected">isItemSelected</a></b> (<i>self</i>, QTableWidgetItem <i>item</i>)</li><li><div class="fn" />bool <b><a href="qtablewidget.html#isSortingEnabled">isSortingEnabled</a></b> (<i>self</i>)</li><li><div class="fn" />QTableWidgetItem <b><a href="qtablewidget.html#item">item</a></b> (<i>self</i>, int <i>row</i>, int <i>column</i>)</li><li><div class="fn" />QTableWidgetItem <b><a href="qtablewidget.html#itemAt">itemAt</a></b> (<i>self</i>, QPoint <i>p</i>)</li><li><div class="fn" />QTableWidgetItem <b><a href="qtablewidget.html#itemAt-2">itemAt</a></b> (<i>self</i>, int <i>ax</i>, int <i>ay</i>)</li><li><div class="fn" />QTableWidgetItem <b><a href="qtablewidget.html#itemFromIndex">itemFromIndex</a></b> (<i>self</i>, QModelIndex <i>index</i>)</li><li><div class="fn" />QTableWidgetItem <b><a href="qtablewidget.html#itemPrototype">itemPrototype</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QTableWidgetItem <b><a href="qtablewidget.html#items">items</a></b> (<i>self</i>, QMimeData <i>data</i>)</li><li><div class="fn" />QMimeData <b><a href="qtablewidget.html#mimeData">mimeData</a></b> (<i>self</i>, list-of-QTableWidgetItem <i>items</i>)</li><li><div class="fn" />QStringList <b><a href="qtablewidget.html#mimeTypes">mimeTypes</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#openPersistentEditor">openPersistentEditor</a></b> (<i>self</i>, QTableWidgetItem <i>item</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#removeCellWidget">removeCellWidget</a></b> (<i>self</i>, int <i>arow</i>, int <i>acolumn</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#removeColumn">removeColumn</a></b> (<i>self</i>, int <i>column</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#removeRow">removeRow</a></b> (<i>self</i>, int <i>row</i>)</li><li><div class="fn" />int <b><a href="qtablewidget.html#row">row</a></b> (<i>self</i>, QTableWidgetItem <i>item</i>)</li><li><div class="fn" />int <b><a href="qtablewidget.html#rowCount">rowCount</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#scrollToItem">scrollToItem</a></b> (<i>self</i>, QTableWidgetItem <i>item</i>, QAbstractItemView.ScrollHint <i>hint</i> = QAbstractItemView.EnsureVisible)</li><li><div class="fn" />list-of-QTableWidgetItem <b><a href="qtablewidget.html#selectedItems">selectedItems</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QTableWidgetSelectionRange <b><a href="qtablewidget.html#selectedRanges">selectedRanges</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setCellWidget">setCellWidget</a></b> (<i>self</i>, int <i>row</i>, int <i>column</i>, QWidget <i>widget</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setColumnCount">setColumnCount</a></b> (<i>self</i>, int <i>columns</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setCurrentCell">setCurrentCell</a></b> (<i>self</i>, int <i>row</i>, int <i>column</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setCurrentCell-2">setCurrentCell</a></b> (<i>self</i>, int <i>row</i>, int <i>column</i>, QItemSelectionModel.SelectionFlags <i>command</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setCurrentItem">setCurrentItem</a></b> (<i>self</i>, QTableWidgetItem <i>item</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setCurrentItem-2">setCurrentItem</a></b> (<i>self</i>, QTableWidgetItem <i>item</i>, QItemSelectionModel.SelectionFlags <i>command</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setHorizontalHeaderItem">setHorizontalHeaderItem</a></b> (<i>self</i>, int <i>column</i>, QTableWidgetItem <i>item</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setHorizontalHeaderLabels">setHorizontalHeaderLabels</a></b> (<i>self</i>, QStringList <i>labels</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setItem">setItem</a></b> (<i>self</i>, int <i>row</i>, int <i>column</i>, QTableWidgetItem <i>item</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setItemPrototype">setItemPrototype</a></b> (<i>self</i>, QTableWidgetItem <i>item</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setItemSelected">setItemSelected</a></b> (<i>self</i>, QTableWidgetItem <i>item</i>, bool <i>select</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setRangeSelected">setRangeSelected</a></b> (<i>self</i>, QTableWidgetSelectionRange <i>range</i>, bool <i>select</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setRowCount">setRowCount</a></b> (<i>self</i>, int <i>rows</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setSortingEnabled">setSortingEnabled</a></b> (<i>self</i>, bool <i>enable</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setVerticalHeaderItem">setVerticalHeaderItem</a></b> (<i>self</i>, int <i>row</i>, QTableWidgetItem <i>item</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#setVerticalHeaderLabels">setVerticalHeaderLabels</a></b> (<i>self</i>, QStringList <i>labels</i>)</li><li><div class="fn" /><b><a href="qtablewidget.html#sortItems">sortItems</a></b> (<i>self</i>, int <i>column</i>, Qt.SortOrder <i>order</i> = Qt.AscendingOrder)</li><li><div class="fn" />Qt.DropActions <b><a href="qtablewidget.html#supportedDropActions">supportedDropActions</a></b> (<i>self</i>)</li><li><div class="fn" />QTableWidgetItem <b><a href="qtablewidget.html#takeHorizontalHeaderItem">takeHorizontalHeaderItem</a></b> (<i>self</i>, int <i>column</i>)</li><li><div class="fn" />QTableWidgetItem <b><a href="qtablewidget.html#takeItem">takeItem</a></b> (<i>self</i>, int <i>row</i>, int <i>column</i>)</li><li><div class="fn" />QTableWidgetItem <b><a href="qtablewidget.html#takeVerticalHeaderItem">takeVerticalHeaderItem</a></b> (<i>self</i>, int <i>row</i>)</li><li><div class="fn" />QTableWidgetItem <b><a href="qtablewidget.html#verticalHeaderItem">verticalHeaderItem</a></b> (<i>self</i>, int <i>row</i>)</li><li><div class="fn" />int <b><a href="qtablewidget.html#visualColumn">visualColumn</a></b> (<i>self</i>, int <i>logicalColumn</i>)</li><li><div class="fn" />QRect <b><a href="qtablewidget.html#visualItemRect">visualItemRect</a></b> (<i>self</i>, QTableWidgetItem <i>item</i>)</li><li><div class="fn" />int <b><a href="qtablewidget.html#visualRow">visualRow</a></b> (<i>self</i>, int <i>logicalRow</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qtablewidget.html#cellActivated">cellActivated</a></b> (int,int)</li><li><div class="fn" />void <b><a href="qtablewidget.html#cellChanged">cellChanged</a></b> (int,int)</li><li><div class="fn" />void <b><a href="qtablewidget.html#cellClicked">cellClicked</a></b> (int,int)</li><li><div class="fn" />void <b><a href="qtablewidget.html#cellDoubleClicked">cellDoubleClicked</a></b> (int,int)</li><li><div class="fn" />void <b><a href="qtablewidget.html#cellEntered">cellEntered</a></b> (int,int)</li><li><div class="fn" />void <b><a href="qtablewidget.html#cellPressed">cellPressed</a></b> (int,int)</li><li><div class="fn" />void <b><a href="qtablewidget.html#currentCellChanged">currentCellChanged</a></b> (int,int,int,int)</li><li><div class="fn" />void <b><a href="qtablewidget.html#currentItemChanged">currentItemChanged</a></b> (QTableWidgetItem *,QTableWidgetItem *)</li><li><div class="fn" />void <b><a href="qtablewidget.html#itemActivated">itemActivated</a></b> (QTableWidgetItem *)</li><li><div class="fn" />void <b><a href="qtablewidget.html#itemChanged">itemChanged</a></b> (QTableWidgetItem *)</li><li><div class="fn" />void <b><a href="qtablewidget.html#itemClicked">itemClicked</a></b> (QTableWidgetItem *)</li><li><div class="fn" />void <b><a href="qtablewidget.html#itemDoubleClicked">itemDoubleClicked</a></b> (QTableWidgetItem *)</li><li><div class="fn" />void <b><a href="qtablewidget.html#itemEntered">itemEntered</a></b> (QTableWidgetItem *)</li><li><div class="fn" />void <b><a href="qtablewidget.html#itemPressed">itemPressed</a></b> (QTableWidgetItem *)</li><li><div class="fn" />void <b><a href="qtablewidget.html#itemSelectionChanged">itemSelectionChanged</a></b> ()</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QTableWidget class provides an item-based table view with a default model.</p> <p>Table widgets provide standard table display facilities for applications. The items in a QTableWidget are provided by <a href="qtablewidgetitem.html">QTableWidgetItem</a>.</p> <p>If you want a table that uses your own data model you should use <a href="qtableview.html">QTableView</a> rather than this class.</p> <p>Table widgets can be constructed with the required numbers of rows and columns:</p> <pre class="cpp"> tableWidget <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QTableWidget</span>(<span class="number">12</span><span class="operator">,</span> <span class="number">3</span><span class="operator">,</span> <span class="keyword">this</span>); </pre> <p>Alternatively, tables can be constructed without a given size and resized later:</p> <pre class="cpp"> tableWidget <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QTableWidget</span>(<span class="keyword">this</span>); tableWidget<span class="operator">-</span><span class="operator">></span>setRowCount(<span class="number">10</span>); tableWidget<span class="operator">-</span><span class="operator">></span>setColumnCount(<span class="number">5</span>); </pre> <p>Items are created ouside the table (with no parent widget) and inserted into the table with <a href="qtablewidget.html#setItem">setItem</a>():</p> <pre class="cpp"> <span class="type"><a href="qtablewidgetitem.html">QTableWidgetItem</a></span> <span class="operator">*</span>newItem <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qtablewidgetitem.html">QTableWidgetItem</a></span>(tr(<span class="string">"%1"</span>)<span class="operator">.</span>arg( (row<span class="operator">+</span><span class="number">1</span>)<span class="operator">*</span>(column<span class="operator">+</span><span class="number">1</span>))); tableWidget<span class="operator">-</span><span class="operator">></span>setItem(row<span class="operator">,</span> column<span class="operator">,</span> newItem); </pre> <p>If you want to enable sorting in your table widget, do so after you have populated it with items, otherwise sorting may interfere with the insertion order (see <a href="qtablewidget.html#setItem">setItem</a>() for details).</p> <p>Tables can be given both horizontal and vertical headers. The simplest way to create the headers is to supply a list of strings to the <a href="qtablewidget.html#setHorizontalHeaderLabels">setHorizontalHeaderLabels</a>() and <a href="qtablewidget.html#setVerticalHeaderLabels">setVerticalHeaderLabels</a>() functions. These will provide simple textual headers for the table's columns and rows. More sophisticated headers can be created from existing table items that are usually constructed outside the table. For example, we can construct a table item with an icon and aligned text, and use it as the header for a particular column:</p> <pre class="cpp"> <span class="type"><a href="qtablewidgetitem.html">QTableWidgetItem</a></span> <span class="operator">*</span>cubesHeaderItem <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qtablewidgetitem.html">QTableWidgetItem</a></span>(tr(<span class="string">"Cubes"</span>)); cubesHeaderItem<span class="operator">-</span><span class="operator">></span>setIcon(<span class="type"><a href="qicon.html">QIcon</a></span>(<span class="type"><a href="qpixmap.html">QPixmap</a></span>(<span class="string">":/Images/cubed.png"</span>))); cubesHeaderItem<span class="operator">-</span><span class="operator">></span>setTextAlignment(<span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>AlignVCenter); </pre> <p>The number of rows in the table can be found with <a href="qtablewidget.html#rowCount-prop">rowCount</a>(), and the number of columns with <a href="qtablewidget.html#columnCount-prop">columnCount</a>(). The table can be cleared with the <a href="qtablewidget.html#clear">clear</a>() function.</p> <table class="generic" width="100%"> <tr class="odd" valign="top"> <td><img alt="Screenshot of a Windows XP style table widget" src="images/windowsxp-tableview.png" /></td> <td><img alt="Screenshot of a Macintosh style table widget" src="images/macintosh-tableview.png" /></td> <td><img alt="Screenshot of a Plastique style table widget" src="images/plastique-tableview.png" /></td> </tr> <tr class="even" valign="top"> <td>A <a href="gallery-windowsxp.html">Windows XP style</a> table widget.</td> <td>A <a href="gallery-macintosh.html">Macintosh style</a> table widget.</td> <td>A <a href="gallery-plastique.html">Plastique style</a> table widget.</td> </tr> </table> <hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QTableWidget" />QTableWidget.__init__ (<i>self</i>, <a href="qwidget.html">QWidget</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Creates a new table view with the given <i>parent</i>.</p> <h3 class="fn"><a name="QTableWidget-2" />QTableWidget.__init__ (<i>self</i>, int <i>rows</i>, int <i>columns</i>, <a href="qwidget.html">QWidget</a> <i>parent</i> = None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Creates a new table view with the given <i>rows</i> and <i>columns</i>, and with the given <i>parent</i>.</p> <h3 class="fn"><a name="cellWidget" /><a href="qwidget.html">QWidget</a> QTableWidget.cellWidget (<i>self</i>, int <i>row</i>, int <i>column</i>)</h3><p>Returns the widget displayed in the cell in the given <i>row</i> and <i>column</i>.</p> <p><b>Note:</b> The table takes ownership of the widget.</p> <p>This function was introduced in Qt 4.1.</p> <p><b>See also</b> <a href="qtablewidget.html#setCellWidget">setCellWidget</a>().</p> <h3 class="fn"><a name="clear" />QTableWidget.clear (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void clear()</tt>.</p><p>Removes all items in the view. This will also remove all selections. The table dimensions stay the same.</p> <h3 class="fn"><a name="clearContents" />QTableWidget.clearContents (<i>self</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void clearContents()</tt>.</p><p>Removes all items not in the headers from the view. This will also remove all selections. The table dimensions stay the same.</p> <p>This function was introduced in Qt 4.2.</p> <h3 class="fn"><a name="closePersistentEditor" />QTableWidget.closePersistentEditor (<i>self</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>)</h3><p>Closes the persistent editor for <i>item</i>.</p> <p><b>See also</b> <a href="qtablewidget.html#openPersistentEditor">openPersistentEditor</a>().</p> <h3 class="fn"><a name="column" />int QTableWidget.column (<i>self</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>)</h3><p>Returns the column for the <i>item</i>.</p> <h3 class="fn"><a name="columnCount" />int QTableWidget.columnCount (<i>self</i>)</h3><h3 class="fn"><a name="currentColumn" />int QTableWidget.currentColumn (<i>self</i>)</h3><p>Returns the column of the current item.</p> <p><b>See also</b> <a href="qtablewidget.html#currentRow">currentRow</a>() and <a href="qtablewidget.html#setCurrentCell">setCurrentCell</a>().</p> <h3 class="fn"><a name="currentItem" /><a href="qtablewidgetitem.html">QTableWidgetItem</a> QTableWidget.currentItem (<i>self</i>)</h3><p>Returns the current item.</p> <p><b>See also</b> <a href="qtablewidget.html#setCurrentItem">setCurrentItem</a>().</p> <h3 class="fn"><a name="currentRow" />int QTableWidget.currentRow (<i>self</i>)</h3><p>Returns the row of the current item.</p> <p><b>See also</b> <a href="qtablewidget.html#currentColumn">currentColumn</a>() and <a href="qtablewidget.html#setCurrentCell">setCurrentCell</a>().</p> <h3 class="fn"><a name="dropEvent" />QTableWidget.dropEvent (<i>self</i>, <a href="qdropevent.html">QDropEvent</a> <i>event</i>)</h3><p>Reimplemented from <a href="qwidget.html#dropEvent">QWidget.dropEvent</a>().</p> <h3 class="fn"><a name="dropMimeData" />bool QTableWidget.dropMimeData (<i>self</i>, int <i>row</i>, int <i>column</i>, <a href="qmimedata.html">QMimeData</a> <i>data</i>, <a href="qt.html#DropAction-enum">Qt.DropAction</a> <i>action</i>)</h3><p>Handles the <i>data</i> supplied by a drag and drop operation that ended with the given <i>action</i> in the given <i>row</i> and <i>column</i>. Returns true if the data and action can be handled by the model; otherwise returns false.</p> <p><b>See also</b> <a href="qtablewidget.html#supportedDropActions">supportedDropActions</a>().</p> <h3 class="fn"><a name="editItem" />QTableWidget.editItem (<i>self</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>)</h3><p>Starts editing the <i>item</i> if it is editable.</p> <h3 class="fn"><a name="event" />bool QTableWidget.event (<i>self</i>, <a href="qevent.html">QEvent</a> <i>e</i>)</h3><p>Reimplemented from <a href="qobject.html#event">QObject.event</a>().</p> <h3 class="fn"><a name="findItems" />list-of-QTableWidgetItem QTableWidget.findItems (<i>self</i>, QString <i>text</i>, <a href="qt-matchflags.html">Qt.MatchFlags</a> <i>flags</i>)</h3><p>Finds items that matches the <i>text</i> using the given <i>flags</i>.</p> <h3 class="fn"><a name="horizontalHeaderItem" /><a href="qtablewidgetitem.html">QTableWidgetItem</a> QTableWidget.horizontalHeaderItem (<i>self</i>, int <i>column</i>)</h3><p>Returns the horizontal header item for column, <i>column</i>, if one has been set; otherwise returns 0.</p> <p><b>See also</b> <a href="qtablewidget.html#setHorizontalHeaderItem">setHorizontalHeaderItem</a>().</p> <h3 class="fn"><a name="indexFromItem" /><a href="qmodelindex.html">QModelIndex</a> QTableWidget.indexFromItem (<i>self</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>)</h3><p>Returns the <a href="qmodelindex.html">QModelIndex</a> assocated with the given <i>item</i>.</p> <h3 class="fn"><a name="insertColumn" />QTableWidget.insertColumn (<i>self</i>, int <i>column</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void insertColumn(int)</tt>.</p><p>Inserts an empty column into the table at <i>column</i>.</p> <h3 class="fn"><a name="insertRow" />QTableWidget.insertRow (<i>self</i>, int <i>row</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void insertRow(int)</tt>.</p><p>Inserts an empty row into the table at <i>row</i>.</p> <h3 class="fn"><a name="isItemSelected" />bool QTableWidget.isItemSelected (<i>self</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>)</h3><h3 class="fn"><a name="isSortingEnabled" />bool QTableWidget.isSortingEnabled (<i>self</i>)</h3><h3 class="fn"><a name="item" /><a href="qtablewidgetitem.html">QTableWidgetItem</a> QTableWidget.item (<i>self</i>, int <i>row</i>, int <i>column</i>)</h3><p>Returns the item for the given <i>row</i> and <i>column</i> if one has been set; otherwise returns 0.</p> <p><b>See also</b> <a href="qtablewidget.html#setItem">setItem</a>().</p> <h3 class="fn"><a name="itemAt" /><a href="qtablewidgetitem.html">QTableWidgetItem</a> QTableWidget.itemAt (<i>self</i>, <a href="qpoint.html">QPoint</a> <i>p</i>)</h3><p>Returns a pointer to the item at the given <i>point</i>, or returns 0 if <i>point</i> is not covered by an item in the table widget.</p> <p><b>See also</b> <a href="qtablewidget.html#item">item</a>().</p> <h3 class="fn"><a name="itemAt-2" /><a href="qtablewidgetitem.html">QTableWidgetItem</a> QTableWidget.itemAt (<i>self</i>, int <i>ax</i>, int <i>ay</i>)</h3><p>Returns the item at the position equivalent to <a href="qpoint.html">QPoint</a>(<i>ax</i>, <i>ay</i>) in the table widget's coordinate system, or returns 0 if the specified point is not covered by an item in the table widget.</p> <p><b>See also</b> <a href="qtablewidget.html#item">item</a>().</p> <h3 class="fn"><a name="itemFromIndex" /><a href="qtablewidgetitem.html">QTableWidgetItem</a> QTableWidget.itemFromIndex (<i>self</i>, <a href="qmodelindex.html">QModelIndex</a> <i>index</i>)</h3><p>Returns a pointer to the <a href="qtablewidgetitem.html">QTableWidgetItem</a> assocated with the given <i>index</i>.</p> <h3 class="fn"><a name="itemPrototype" /><a href="qtablewidgetitem.html">QTableWidgetItem</a> QTableWidget.itemPrototype (<i>self</i>)</h3><p>Returns the item prototype used by the table.</p> <p><b>See also</b> <a href="qtablewidget.html#setItemPrototype">setItemPrototype</a>().</p> <h3 class="fn"><a name="items" />list-of-QTableWidgetItem QTableWidget.items (<i>self</i>, <a href="qmimedata.html">QMimeData</a> <i>data</i>)</h3><p>Returns a list of pointers to the items contained in the <i>data</i> object. If the object was not created by a <a href="qtreewidget.html">QTreeWidget</a> in the same process, the list is empty.</p> <h3 class="fn"><a name="mimeData" /><a href="qmimedata.html">QMimeData</a> QTableWidget.mimeData (<i>self</i>, list-of-QTableWidgetItem <i>items</i>)</h3><p>The <i>QMimeData</i> result</p><p>Returns an object that contains a serialized description of the specified <i>items</i>. The format used to describe the items is obtained from the <a href="qtablewidget.html#mimeTypes">mimeTypes</a>() function.</p> <p>If the list of items is empty, 0 is returned rather than a serialized empty list.</p> <h3 class="fn"><a name="mimeTypes" />QStringList QTableWidget.mimeTypes (<i>self</i>)</h3><p>Returns a list of MIME types that can be used to describe a list of tablewidget items.</p> <p><b>See also</b> <a href="qtablewidget.html#mimeData">mimeData</a>().</p> <h3 class="fn"><a name="openPersistentEditor" />QTableWidget.openPersistentEditor (<i>self</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>)</h3><p>Opens an editor for the give <i>item</i>. The editor remains open after editing.</p> <p><b>See also</b> <a href="qtablewidget.html#closePersistentEditor">closePersistentEditor</a>().</p> <h3 class="fn"><a name="removeCellWidget" />QTableWidget.removeCellWidget (<i>self</i>, int <i>arow</i>, int <i>acolumn</i>)</h3><p>Removes the widget set on the cell indicated by <i>row</i> and <i>column</i>.</p> <p>This function was introduced in Qt 4.3.</p> <h3 class="fn"><a name="removeColumn" />QTableWidget.removeColumn (<i>self</i>, int <i>column</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void removeColumn(int)</tt>.</p><p>Removes the column <i>column</i> and all its items from the table.</p> <h3 class="fn"><a name="removeRow" />QTableWidget.removeRow (<i>self</i>, int <i>row</i>)</h3><p>This method is also a Qt slot with the C++ signature <tt>void removeRow(int)</tt>.</p><p>Removes the row <i>row</i> and all its items from the table.</p> <h3 class="fn"><a name="row" />int QTableWidget.row (<i>self</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>)</h3><p>Returns the row for the <i>item</i>.</p> <h3 class="fn"><a name="rowCount" />int QTableWidget.rowCount (<i>self</i>)</h3><h3 class="fn"><a name="scrollToItem" />QTableWidget.scrollToItem (<i>self</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>, <a href="qabstractitemview.html#ScrollHint-enum">QAbstractItemView.ScrollHint</a> <i>hint</i> = QAbstractItemView.EnsureVisible)</h3><p>This method is also a Qt slot with the C++ signature <tt>void scrollToItem(const QTableWidgetItem *,QAbstractItemView::ScrollHint = QAbstractItemView.EnsureVisible)</tt>.</p><p>Scrolls the view if necessary to ensure that the <i>item</i> is visible. The <i>hint</i> parameter specifies more precisely where the <i>item</i> should be located after the operation.</p> <h3 class="fn"><a name="selectedItems" />list-of-QTableWidgetItem QTableWidget.selectedItems (<i>self</i>)</h3><p>Returns a list of all selected items.</p> <p>This function returns a list of pointers to the contents of the selected cells. Use the <a href="qtableview.html#selectedIndexes">selectedIndexes</a>() function to retrieve the complete selection <i>including</i> empty cells.</p> <p><b>See also</b> <a href="qtableview.html#selectedIndexes">selectedIndexes</a>().</p> <h3 class="fn"><a name="selectedRanges" />list-of-QTableWidgetSelectionRange QTableWidget.selectedRanges (<i>self</i>)</h3><p>Returns a list of all selected ranges.</p> <p><b>See also</b> <a href="qtablewidgetselectionrange.html">QTableWidgetSelectionRange</a>.</p> <h3 class="fn"><a name="setCellWidget" />QTableWidget.setCellWidget (<i>self</i>, int <i>row</i>, int <i>column</i>, <a href="qwidget.html">QWidget</a> <i>widget</i>)</h3><p>The <i>widget</i> argument has it's ownership transferred to Qt.</p><p>Sets the given <i>widget</i> to be displayed in the cell in the given <i>row</i> and <i>column</i>, passing the ownership of the widget to the table.</p> <p>If cell widget A is replaced with cell widget B, cell widget A will be deleted. For example, in the code snippet below, the <a href="qlineedit.html">QLineEdit</a> object will be deleted.</p> <pre class="cpp"> setCellWidget(index<span class="operator">,</span> <span class="keyword">new</span> <span class="type"><a href="qlineedit.html">QLineEdit</a></span>); <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span> setCellWidget(index<span class="operator">,</span> <span class="keyword">new</span> <span class="type"><a href="qtextedit.html">QTextEdit</a></span>); </pre> <p>This function was introduced in Qt 4.1.</p> <p><b>See also</b> <a href="qtablewidget.html#cellWidget">cellWidget</a>().</p> <h3 class="fn"><a name="setColumnCount" />QTableWidget.setColumnCount (<i>self</i>, int <i>columns</i>)</h3><h3 class="fn"><a name="setCurrentCell" />QTableWidget.setCurrentCell (<i>self</i>, int <i>row</i>, int <i>column</i>)</h3><p>Sets the current cell to be the cell at position (<i>row</i>, <i>column</i>).</p> <p>Depending on the current <a href="qabstractitemview.html#SelectionMode-enum">selection mode</a>, the cell may also be selected.</p> <p>This function was introduced in Qt 4.1.</p> <p><b>See also</b> <a href="qtablewidget.html#setCurrentItem">setCurrentItem</a>(), <a href="qtablewidget.html#currentRow">currentRow</a>(), and <a href="qtablewidget.html#currentColumn">currentColumn</a>().</p> <h3 class="fn"><a name="setCurrentCell-2" />QTableWidget.setCurrentCell (<i>self</i>, int <i>row</i>, int <i>column</i>, <a href="qitemselectionmodel-selectionflags.html">QItemSelectionModel.SelectionFlags</a> <i>command</i>)</h3><p>Sets the current cell to be the cell at position (<i>row</i>, <i>column</i>), using the given <i>command</i>.</p> <p>This function was introduced in Qt 4.4.</p> <p><b>See also</b> <a href="qtablewidget.html#setCurrentItem">setCurrentItem</a>(), <a href="qtablewidget.html#currentRow">currentRow</a>(), and <a href="qtablewidget.html#currentColumn">currentColumn</a>().</p> <h3 class="fn"><a name="setCurrentItem" />QTableWidget.setCurrentItem (<i>self</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>)</h3><p>Sets the current item to <i>item</i>.</p> <p>Unless the selection mode is <a href="qabstractitemview.html#SelectionMode-enum">NoSelection</a>, the item is also be selected.</p> <p><b>See also</b> <a href="qtablewidget.html#currentItem">currentItem</a>() and <a href="qtablewidget.html#setCurrentCell">setCurrentCell</a>().</p> <h3 class="fn"><a name="setCurrentItem-2" />QTableWidget.setCurrentItem (<i>self</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>, <a href="qitemselectionmodel-selectionflags.html">QItemSelectionModel.SelectionFlags</a> <i>command</i>)</h3><p>Sets the current item to be <i>item</i>, using the given <i>command</i>.</p> <p>This function was introduced in Qt 4.4.</p> <p><b>See also</b> <a href="qtablewidget.html#currentItem">currentItem</a>() and <a href="qtablewidget.html#setCurrentCell">setCurrentCell</a>().</p> <h3 class="fn"><a name="setHorizontalHeaderItem" />QTableWidget.setHorizontalHeaderItem (<i>self</i>, int <i>column</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>)</h3><p>The <i>item</i> argument has it's ownership transferred to Qt.</p><p>Sets the horizontal header item for column <i>column</i> to <i>item</i>.</p> <p><b>See also</b> <a href="qtablewidget.html#horizontalHeaderItem">horizontalHeaderItem</a>().</p> <h3 class="fn"><a name="setHorizontalHeaderLabels" />QTableWidget.setHorizontalHeaderLabels (<i>self</i>, QStringList <i>labels</i>)</h3><p>Sets the horizontal header labels using <i>labels</i>.</p> <h3 class="fn"><a name="setItem" />QTableWidget.setItem (<i>self</i>, int <i>row</i>, int <i>column</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>)</h3><p>The <i>item</i> argument has it's ownership transferred to Qt.</p><p>Sets the item for the given <i>row</i> and <i>column</i> to <i>item</i>.</p> <p>The table takes ownership of the item.</p> <p>Note that if sorting is enabled (see <a href="qtableview.html#sortingEnabled-prop">sortingEnabled</a>) and <i>column</i> is the current sort column, the <i>row</i> will be moved to the sorted position determined by <i>item</i>.</p> <p>If you want to set several items of a particular row (say, by calling setItem() in a loop), you may want to turn off sorting before doing so, and turn it back on afterwards; this will allow you to use the same <i>row</i> argument for all items in the same row (i.e. setItem() will not move the row).</p> <p><b>See also</b> <a href="qtablewidget.html#item">item</a>() and <a href="qtablewidget.html#takeItem">takeItem</a>().</p> <h3 class="fn"><a name="setItemPrototype" />QTableWidget.setItemPrototype (<i>self</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>)</h3><p>The <i>item</i> argument has it's ownership transferred to Qt.</p><p>Sets the item prototype for the table to the specified <i>item</i>.</p> <p>The table widget will use the item prototype clone function when it needs to create a new table item. For example when the user is editing in an empty cell. This is useful when you have a <a href="qtablewidgetitem.html">QTableWidgetItem</a> subclass and want to make sure that <a href="qtablewidget.html">QTableWidget</a> creates instances of your subclass.</p> <p>The table takes ownership of the prototype.</p> <p><b>See also</b> <a href="qtablewidget.html#itemPrototype">itemPrototype</a>().</p> <h3 class="fn"><a name="setItemSelected" />QTableWidget.setItemSelected (<i>self</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>, bool <i>select</i>)</h3><h3 class="fn"><a name="setRangeSelected" />QTableWidget.setRangeSelected (<i>self</i>, <a href="qtablewidgetselectionrange.html">QTableWidgetSelectionRange</a> <i>range</i>, bool <i>select</i>)</h3><p>Selects or deselects the <i>range</i> depending on <i>select</i>.</p> <h3 class="fn"><a name="setRowCount" />QTableWidget.setRowCount (<i>self</i>, int <i>rows</i>)</h3><h3 class="fn"><a name="setSortingEnabled" />QTableWidget.setSortingEnabled (<i>self</i>, bool <i>enable</i>)</h3><h3 class="fn"><a name="setVerticalHeaderItem" />QTableWidget.setVerticalHeaderItem (<i>self</i>, int <i>row</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>)</h3><p>The <i>item</i> argument has it's ownership transferred to Qt.</p><p>Sets the vertical header item for row <i>row</i> to <i>item</i>.</p> <p><b>See also</b> <a href="qtablewidget.html#verticalHeaderItem">verticalHeaderItem</a>().</p> <h3 class="fn"><a name="setVerticalHeaderLabels" />QTableWidget.setVerticalHeaderLabels (<i>self</i>, QStringList <i>labels</i>)</h3><p>Sets the vertical header labels using <i>labels</i>.</p> <h3 class="fn"><a name="sortItems" />QTableWidget.sortItems (<i>self</i>, int <i>column</i>, <a href="qt.html#SortOrder-enum">Qt.SortOrder</a> <i>order</i> = Qt.AscendingOrder)</h3><p>Sorts all the rows in the table widget based on <i>column</i> and <i>order</i>.</p> <h3 class="fn"><a name="supportedDropActions" /><a href="qt-dropactions.html">Qt.DropActions</a> QTableWidget.supportedDropActions (<i>self</i>)</h3><p>Returns the drop actions supported by this view.</p> <p><b>See also</b> <a href="qt.html#DropAction-enum">Qt.DropActions</a>.</p> <h3 class="fn"><a name="takeHorizontalHeaderItem" /><a href="qtablewidgetitem.html">QTableWidgetItem</a> QTableWidget.takeHorizontalHeaderItem (<i>self</i>, int <i>column</i>)</h3><p>The <i>QTableWidgetItem</i> result</p><p>Removes the horizontal header item at <i>column</i> from the header without deleting it.</p> <p>This function was introduced in Qt 4.1.</p> <h3 class="fn"><a name="takeItem" /><a href="qtablewidgetitem.html">QTableWidgetItem</a> QTableWidget.takeItem (<i>self</i>, int <i>row</i>, int <i>column</i>)</h3><p>The <i>QTableWidgetItem</i> result</p><p>Removes the item at <i>row</i> and <i>column</i> from the table without deleting it.</p> <h3 class="fn"><a name="takeVerticalHeaderItem" /><a href="qtablewidgetitem.html">QTableWidgetItem</a> QTableWidget.takeVerticalHeaderItem (<i>self</i>, int <i>row</i>)</h3><p>The <i>QTableWidgetItem</i> result</p><p>Removes the vertical header item at <i>row</i> from the header without deleting it.</p> <p>This function was introduced in Qt 4.1.</p> <h3 class="fn"><a name="verticalHeaderItem" /><a href="qtablewidgetitem.html">QTableWidgetItem</a> QTableWidget.verticalHeaderItem (<i>self</i>, int <i>row</i>)</h3><p>Returns the vertical header item for row <i>row</i>.</p> <p><b>See also</b> <a href="qtablewidget.html#setVerticalHeaderItem">setVerticalHeaderItem</a>().</p> <h3 class="fn"><a name="visualColumn" />int QTableWidget.visualColumn (<i>self</i>, int <i>logicalColumn</i>)</h3><p>Returns the visual column of the given <i>logicalColumn</i>.</p> <h3 class="fn"><a name="visualItemRect" /><a href="qrect.html">QRect</a> QTableWidget.visualItemRect (<i>self</i>, <a href="qtablewidgetitem.html">QTableWidgetItem</a> <i>item</i>)</h3><p>Returns the rectangle on the viewport occupied by the item at <i>item</i>.</p> <h3 class="fn"><a name="visualRow" />int QTableWidget.visualRow (<i>self</i>, int <i>logicalRow</i>)</h3><p>Returns the visual row of the given <i>logicalRow</i>.</p> <hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="cellActivated" />void cellActivated (int,int)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the cell specified by <i>row</i> and <i>column</i> has been activated</p> <p>This function was introduced in Qt 4.1.</p> <h3 class="fn"><a name="cellChanged" />void cellChanged (int,int)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever the data of the item in the cell specified by <i>row</i> and <i>column</i> has changed.</p> <p>This function was introduced in Qt 4.1.</p> <h3 class="fn"><a name="cellClicked" />void cellClicked (int,int)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever a cell in the table is clicked. The <i>row</i> and <i>column</i> specified is the cell that was clicked.</p> <p>This function was introduced in Qt 4.1.</p> <h3 class="fn"><a name="cellDoubleClicked" />void cellDoubleClicked (int,int)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever a cell in the table is double clicked. The <i>row</i> and <i>column</i> specified is the cell that was double clicked.</p> <p>This function was introduced in Qt 4.1.</p> <h3 class="fn"><a name="cellEntered" />void cellEntered (int,int)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the mouse cursor enters a cell. The cell is specified by <i>row</i> and <i>column</i>.</p> <p>This signal is only emitted when <a href="qwidget.html#mouseTracking-prop">mouseTracking</a> is turned on, or when a mouse button is pressed while moving into an item.</p> <p>This function was introduced in Qt 4.1.</p> <h3 class="fn"><a name="cellPressed" />void cellPressed (int,int)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever a cell in the table is pressed. The <i>row</i> and <i>column</i> specified is the cell that was pressed.</p> <p>This function was introduced in Qt 4.1.</p> <h3 class="fn"><a name="currentCellChanged" />void currentCellChanged (int,int,int,int)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever the current cell changes. The cell specified by <i>previousRow</i> and <i>previousColumn</i> is the cell that previously had the focus, the cell specified by <i>currentRow</i> and <i>currentColumn</i> is the new current cell.</p> <p>This function was introduced in Qt 4.1.</p> <h3 class="fn"><a name="currentItemChanged" />void currentItemChanged (QTableWidgetItem *,QTableWidgetItem *)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever the current item changes. The <i>previous</i> item is the item that previously had the focus, <i>current</i> is the new current item.</p> <h3 class="fn"><a name="itemActivated" />void itemActivated (QTableWidgetItem *)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the specified <i>item</i> has been activated</p> <h3 class="fn"><a name="itemChanged" />void itemChanged (QTableWidgetItem *)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever the data of <i>item</i> has changed.</p> <h3 class="fn"><a name="itemClicked" />void itemClicked (QTableWidgetItem *)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever an item in the table is clicked. The <i>item</i> specified is the item that was clicked.</p> <h3 class="fn"><a name="itemDoubleClicked" />void itemDoubleClicked (QTableWidgetItem *)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever an item in the table is double clicked. The <i>item</i> specified is the item that was double clicked.</p> <h3 class="fn"><a name="itemEntered" />void itemEntered (QTableWidgetItem *)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted when the mouse cursor enters an item. The <i>item</i> is the item entered.</p> <p>This signal is only emitted when <a href="qwidget.html#mouseTracking-prop">mouseTracking</a> is turned on, or when a mouse button is pressed while moving into an item.</p> <h3 class="fn"><a name="itemPressed" />void itemPressed (QTableWidgetItem *)</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever an item in the table is pressed. The <i>item</i> specified is the item that was pressed.</p> <h3 class="fn"><a name="itemSelectionChanged" />void itemSelectionChanged ()</h3><p>This is the default overload of this signal.</p><p>This signal is emitted whenever the selection changes.</p> <p><b>See also</b> <a href="qtablewidget.html#selectedItems">selectedItems</a>() and <a href="qtablewidgetitem.html#isSelected">QTableWidgetItem.isSelected</a>().</p> <address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>