Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QTableWidget

    java.lang.Object
      com.trolltech.qt.QSignalEmitter
          com.trolltech.qt.QtJambiObject
              com.trolltech.qt.core.QObject
                  com.trolltech.qt.gui.QWidget
                      com.trolltech.qt.gui.QFrame
                          com.trolltech.qt.gui.QAbstractScrollArea
                              com.trolltech.qt.gui.QAbstractItemView
                                  com.trolltech.qt.gui.QTableView
                                      com.trolltech.qt.gui.QTableWidget

All Implemented Interfaces:
  QPaintDeviceInterface, QtJambiInterface

    public class QTableWidget

extends QTableView

The `QTableWidget` class provides an item-based table view with a default model. Table widgets provide standard table display facilities for applications. The items in a `QTableWidget` are provided by `QTableWidgetItem`.

If you want a table that uses your own data model you should use `QTableView` rather than this class.

Table widgets can be constructed with the required numbers of rows and columns:

            tableWidget = new QTableWidget(12, 3, this);

Alternatively, tables can be constructed without a given size and resized later:

            tableWidget = new QTableWidget(this);

            tableWidget.setRowCount(10);
            tableWidget.setColumnCount(5);

Items are created ouside the table (with no parent widget) and inserted into the table with `setItem()`:

            QTableWidgetItem newItem = new QTableWidgetItem("" + (row+1) + ", " + (column+1));
            tableWidget.setItem(row, column, newItem);

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 `setItem()` for details).

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 `setHorizontalHeaderLabels()` and `setVerticalHeaderLabels()` 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:

            QTableWidgetItem cubesHeaderItem = new QTableWidgetItem(tr("Cubes"));
            cubesHeaderItem.setIcon(new QIcon(new QPixmap("classpath:images/cubed.png")));
            cubesHeaderItem.setTextAlignment(Qt.AlignmentFlag.AlignVCenter.value());

The number of rows in the table can be found with `rowCount()`, and the number of columns with `columnCount()`. The table can be cleared with the `clear()` function.

A Windows XP style table widget. | A Macintosh style table widget. | A Plastique style table widget.

See also:
  `QTableWidgetItem`, `QTableView`, and Model/View Programming.

Nested Class Summary

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QAbstractItemView
`QAbstractItemView.CursorAction, QAbstractItemView.DragDropMode, QAbstractItemView.DropIndicatorPosition, QAbstractItemView.EditTrigger, QAbstractItemView.EditTriggers, QAbstractItemView.ScrollHint, QAbstractItemView.ScrollMode, QAbstractItemView.SelectionBehavior, QAbstractItemView.SelectionMode, QAbstractItemView.State`

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QFrame
`QFrame.Shadow, QFrame.Shape, QFrame.StyleMask`

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
`QWidget.RenderFlag, QWidget.RenderFlags`

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Field Summary
`QSignalEmitter.Signal2` | `cellActivated` This signal is emitted when the cell specified by `row` and `column` has been activated
`QSignalEmitter.Signal2` | `cellChanged` This signal is emitted whenever the data of the item in the cell specified by `row` and `column` has changed.
`QSignalEmitter.Signal2` | `cellClicked` This signal is emitted whenever a cell in the table is clicked.
`QSignalEmitter.Signal2` | `cellDoubleClicked` This signal is emitted whenever a cell in the table is double clicked.
`QSignalEmitter.Signal2` | `cellEntered` This signal is emitted when the mouse cursor enters a cell.
`QSignalEmitter.Signal2` | `cellPressed` This signal is emitted whenever a cell the table is pressed.
`QSignalEmitter.Signal4` | `currentCellChanged` This signal is emitted whenever the current cell changes.
`QSignalEmitter.Signal2` | `currentItemChanged` This signal is emitted whenever the current item changes.
`QSignalEmitter.Signal1` | `itemActivated` This signal is emitted when the specified `item` has been activated
`QSignalEmitter.Signal1` | `itemChanged` This signal is emitted whenever the data of `item` has changed.
`QSignalEmitter.Signal1` | `itemClicked` This signal is emitted whenever an item in the table is clicked.
`QSignalEmitter.Signal1` | `itemDoubleClicked` This signal is emitted whenever an item in the table is double clicked.
`QSignalEmitter.Signal1` | `itemEntered` This signal is emitted when the mouse cursor enters an item.
`QSignalEmitter.Signal1` | `itemPressed` This signal is emitted whenever an item in the table is pressed.
`QSignalEmitter.Signal0` | `itemSelectionChanged` This signal is emitted whenever the selection changes.

Fields inherited from class com.trolltech.qt.gui.QAbstractItemView
`activated, clicked, doubleClicked, entered, pressed, viewportEntered`

Fields inherited from class com.trolltech.qt.gui.QWidget
`customContextMenuRequested`

Constructor Summary
`QTableWidget()` Creates a new table view with the given `parent`.
`QTableWidget(int rows, int columns)` Creates a new table view with the given `rows` and `columns`, and with the given `parent`.
`QTableWidget(int rows, int columns, QWidget parent)` Creates a new table view with the given `rows` and `columns`, and with the given `parent`.
`QTableWidget(QWidget parent)` Creates a new table view with the given `parent`.

Method Summary
`QWidget` | `cellWidget(int row, int column)` Returns the widget displayed in the cell in the given `row` and `column`.
`void` | `clear()` Removes all items in the view.
`void` | `clearContents()` Removes all items not in the headers from the view.
`void` | `closePersistentEditor(QTableWidgetItem item)` Closes the persistent editor for `item`.
`int` | `column(QTableWidgetItem item)` Returns the column for the `item`.
`int` | `columnCount()` This property holds the number of columns in the table.
`int` | `currentColumn()` Returns the column of the current item.
`QTableWidgetItem` | `currentItem()` Returns the current item.
`int` | `currentRow()` Returns the row of the current item.
`protected boolean` | `dropMimeData(int row, int column, QMimeData data, Qt.DropAction action)` Handles the `data` supplied by a drag and drop operation that ended with the given `action` in the given `row` and `column`.
`void` | `editItem(QTableWidgetItem item)` Starts editing the `item` if it is editable.
`java.util.List` | `findItems(java.lang.String text, Qt.MatchFlag[] flags)` Finds items that matches the `text` using the given `flags`.
`java.util.List` | `findItems(java.lang.String text, Qt.MatchFlags flags)` Finds items that matches the `text` using the given `flags`.
`static QTableWidget` | `fromNativePointer(QNativePointer nativePointer)` This method returns the QTableWidget instance pointed to by `nativePointer`.
`QTableWidgetItem` | `horizontalHeaderItem(int column)` Returns the horizontal header item for column, `column`, if one has been set; otherwise returns 0.
`protected QModelIndex` | `indexFromItem(QTableWidgetItem item)` Returns the QModelIndex assocated with the given `item`.
`void` | `insertColumn(int column)` Inserts an empty column into the table at `column`.
`void` | `insertRow(int row)` Inserts an empty row into the table at `row`.
`QTableWidgetItem` | `item(int row, int column)` Returns the item for the given `row` and `column` if one has been set; otherwise returns 0.
`QTableWidgetItem` | `itemAt(int x, int y)` Returns the item at the position equivalent to `QPoint`(`ax`, `ay`) in the table widget's coordinate system, or returns 0 if the specified point is not covered by an item in the table widget.
`QTableWidgetItem` | `itemAt(QPoint p)` Returns a pointer to the item at the given `point`, or returns 0 if the point is not covered by an item in the table widget.
`protected QTableWidgetItem` | `itemFromIndex(QModelIndex index)` Returns a pointer to the `QTableWidgetItem` assocated with the given `index`.
`QTableWidgetItem` | `itemPrototype()` Returns the item prototype used by the table.
`protected java.util.List` | `items(QMimeData data)` Returns a list of pointers to the items contained in the `data` object.
`protected QMimeData` | `mimeData(java.util.List items)` Returns an object that contains a serialized description of the specified `items`.
`protected java.util.List` | `mimeTypes()` Returns a list of MIME types that can be used to describe a list of tablewidget items.
`void` | `openPersistentEditor(QTableWidgetItem item)` Opens an editor for the give `item`.
`void` | `removeCellWidget(int row, int column)` Removes the widget set on the cell indicated by `row` and `column`.
`void` | `removeColumn(int column)` Removes the column `column` and all its items from the table.
`void` | `removeRow(int row)` Removes the row `row` and all its items from the table.
`int` | `row(QTableWidgetItem item)` Returns the row for the `item`.
`int` | `rowCount()` This property holds the number of rows in the table.
`void` | `scrollToItem(QTableWidgetItem item)` Scrolls the view if necessary to ensure that the `item` is visible.
`void` | `scrollToItem(QTableWidgetItem item, QAbstractItemView.ScrollHint hint)` Scrolls the view if necessary to ensure that the `item` is visible.
`java.util.List` | `selectedItems()` Returns a list of all selected items.
`java.util.List` | `selectedRanges()` Returns a list of all selected ranges.
`void` | `setCellWidget(int row, int column, QWidget widget)` Sets the `widget` to be displayed in the cell in the given `row` and `column`.
`void` | `setColumnCount(int columns)` This property holds the number of columns in the table.
`void` | `setCurrentCell(int row, int column)` Sets the current cell to be the cell at position (`row`, `column`).
`void` | `setCurrentCell(int row, int column, QItemSelectionModel.SelectionFlag[] command)` Sets the current cell to be the cell at position (`row`, `column`), using the given `command`.
`void` | `setCurrentCell(int row, int column, QItemSelectionModel.SelectionFlags command)` Sets the current cell to be the cell at position (`row`, `column`), using the given `command`.
`void` | `setCurrentItem(QTableWidgetItem item)` Sets the current item to `item`.
`void` | `setCurrentItem(QTableWidgetItem item, QItemSelectionModel.SelectionFlag[] command)` Sets the current item to be `item`, using the given `command`.
`void` | `setCurrentItem(QTableWidgetItem item, QItemSelectionModel.SelectionFlags command)` Sets the current item to be `item`, using the given `command`.
`void` | `setHorizontalHeaderItem(int column, QTableWidgetItem item)` Sets the horizontal header item for column `column` to `item`.
`void` | `setHorizontalHeaderLabels(java.util.List labels)` Sets the horizontal header labels using `labels`.
`void` | `setItem(int row, int column, QTableWidgetItem item)` Sets the item for the given `row` and `column` to `item`.
`void` | `setItemPrototype(QTableWidgetItem item)` Sets the item prototype for the table to the specified `item`.
`void` | `setRangeSelected(QTableWidgetSelectionRange range, boolean select)` Selects or deselects the `range` depending on `select`.
`void` | `setRowCount(int rows)` This property holds the number of rows in the table.
`void` | `setVerticalHeaderItem(int row, QTableWidgetItem item)` Sets the vertical header item for row `row` to `item`.
`void` | `setVerticalHeaderLabels(java.util.List labels)` Sets the vertical header labels using `labels`.
`void` | `sortItems(int column)` Sorts all the rows in the table widget based on `column` and `order`.
`void` | `sortItems(int column, Qt.SortOrder order)` Sorts all the rows in the table widget based on `column` and `order`.
`protected Qt.DropActions` | `supportedDropActions()` Returns the drop actions supported by this view.
`QTableWidgetItem` | `takeHorizontalHeaderItem(int column)` Removes the horizontal header item at `column` from the header without deleting it.
`QTableWidgetItem` | `takeItem(int row, int column)` Removes the item at `row` and `column` from the table without deleting it.
`QTableWidgetItem` | `takeVerticalHeaderItem(int row)` Removes the vertical header item at `row` from the header without deleting it.
`QTableWidgetItem` | `verticalHeaderItem(int row)` Returns the vertical header item for row `row`.
`int` | `visualColumn(int logicalColumn)` Returns the visual column of the given `logicalColumn`.
`QRect` | `visualItemRect(QTableWidgetItem item)` Returns the rectangle on the viewport occupied by the item at `item`.
`int` | `visualRow(int logicalRow)` Returns the visual row of the given `logicalRow`.

Methods inherited from class com.trolltech.qt.gui.QTableView
`clearSpans, columnAt, columnCountChanged, columnMoved, columnResized, columnSpan, columnViewportPosition, columnWidth, gridStyle, hideColumn, hideRow, horizontalHeader, isColumnHidden, isCornerButtonEnabled, isRowHidden, isSortingEnabled, resizeColumnsToContents, resizeColumnToContents, resizeRowsToContents, resizeRowToContents, rowAt, rowCountChanged, rowHeight, rowMoved, rowResized, rowSpan, rowViewportPosition, selectColumn, selectRow, setColumnHidden, setColumnWidth, setCornerButtonEnabled, setGridStyle, setHorizontalHeader, setRowHeight, setRowHidden, setShowGrid, setSortingEnabled, setSpan, setVerticalHeader, setWordWrap, showColumn, showGrid, showRow, sortByColumn, verticalHeader, wordWrap`

Methods inherited from class com.trolltech.qt.gui.QAbstractItemView
`alternatingRowColors, autoScrollMargin, clearSelection, closeEditor, closePersistentEditor, commitData, currentChanged, currentIndex, dataChanged, dirtyRegionOffset, dragDropMode, dragDropOverwriteMode, dragEnabled, dropIndicatorPosition, edit, edit, editorDestroyed, editTriggers, executeDelayedItemsLayout, hasAutoScroll, horizontalOffset, horizontalScrollMode, iconSize, indexAt, indexWidget, isIndexHidden, itemDelegate, itemDelegate, itemDelegateForColumn, itemDelegateForRow, keyboardSearch, model, moveCursor, openPersistentEditor, reset, rootIndex, rowsAboutToBeRemoved, rowsInserted, scheduleDelayedItemsLayout, scrollDirtyRegion, scrollTo, scrollTo, scrollToBottom, scrollToTop, selectAll, selectedIndexes, selectionBehavior, selectionChanged, selectionCommand, selectionCommand, selectionMode, selectionModel, setAlternatingRowColors, setAutoScroll, setAutoScrollMargin, setCurrentIndex, setDirtyRegion, setDragDropMode, setDragDropOverwriteMode, setDragEnabled, setDropIndicatorShown, setEditTriggers, setEditTriggers, setHorizontalScrollMode, setIconSize, setIndexWidget, setItemDelegate, setItemDelegateForColumn, setItemDelegateForRow, setModel, setRootIndex, setSelection, setSelectionBehavior, setSelectionMode, setSelectionModel, setState, setTabKeyNavigation, setTextElideMode, setVerticalScrollMode, showDropIndicator, sizeHintForColumn, sizeHintForIndex, sizeHintForRow, startDrag, startDrag, state, tabKeyNavigation, textElideMode, update, updateGeometries, verticalOffset, verticalScrollMode, viewOptions, visualRect, visualRegionForSelection`

Methods inherited from class com.trolltech.qt.gui.QAbstractScrollArea
`addScrollBarWidget, addScrollBarWidget, cornerWidget, horizontalScrollBar, horizontalScrollBarPolicy, maximumViewportSize, scrollBarWidgets, scrollBarWidgets, scrollContentsBy, setCornerWidget, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setupViewport, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportMargins, verticalScrollBar, verticalScrollBarPolicy, viewport, viewportEvent`

Methods inherited from class com.trolltech.qt.gui.QFrame
`frameRect, frameShadow, frameShape, frameStyle, frameWidth, lineWidth, midLineWidth, setFrameRect, setFrameShadow, setFrameShape, setFrameStyle, setLineWidth, setMidLineWidth`

Methods inherited from class com.trolltech.qt.gui.QWidget
`acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, changeEvent, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, cursor, depth, destroy, destroy, destroy, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, effectiveWinId, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isMaximized, isMinimized, isModal, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, languageChange, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nativeParentWidget, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, paintEngine, paintEvent, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFilePath, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFilePath, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y`

Methods inherited from class com.trolltech.qt.core.QObject
`childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty`

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Field Detail

### cellActivated

    public final QSignalEmitter.Signal2 cellActivated

  This signal is emitted when the cell specified by `row` and `column` has been activated

### cellChanged

    public final QSignalEmitter.Signal2 cellChanged

  This signal is emitted whenever the data of the item in the cell specified by `row` and `column` has changed.

### cellClicked

    public final QSignalEmitter.Signal2 cellClicked

  This signal is emitted whenever a cell in the table is clicked. The `row` and `column` specified is the cell that was clicked.

### cellDoubleClicked

    public final QSignalEmitter.Signal2 cellDoubleClicked

  This signal is emitted whenever a cell in the table is double clicked. The `row` and `column` specified is the cell that was double clicked.

### cellEntered

    public final QSignalEmitter.Signal2 cellEntered

  This signal is emitted when the mouse cursor enters a cell. The cell is specified by `row` and `column`.

  This signal is only emitted when `mouseTracking` is turned on, or when a mouse button is pressed while moving into an item.

### cellPressed

    public final QSignalEmitter.Signal2 cellPressed

  This signal is emitted whenever a cell the table is pressed. The `row` and `column` specified is the cell that was pressed.

### currentCellChanged

    public final QSignalEmitter.Signal4 currentCellChanged

  This signal is emitted whenever the current cell changes. The cell specified by `previousRow` and `previousColumn` is the cell that previously had the focus, the cell specified by `currentRow` and `currentColumn` is the new current cell.

### currentItemChanged

    public final QSignalEmitter.Signal2 currentItemChanged

  This signal is emitted whenever the current item changes. The `previous` item is the item that previously had the focus, `current` is the new current item.

### itemActivated

    public final QSignalEmitter.Signal1 itemActivated

  This signal is emitted when the specified `item` has been activated

### itemChanged

    public final QSignalEmitter.Signal1 itemChanged

  This signal is emitted whenever the data of `item` has changed.

### itemClicked

    public final QSignalEmitter.Signal1 itemClicked

  This signal is emitted whenever an item in the table is clicked. The `item` specified is the item that was clicked.

### itemDoubleClicked

    public final QSignalEmitter.Signal1 itemDoubleClicked

  This signal is emitted whenever an item in the table is double clicked. The `item` specified is the item that was double clicked.

### itemEntered

    public final QSignalEmitter.Signal1 itemEntered

  This signal is emitted when the mouse cursor enters an item. The `item` is the item entered.

  This signal is only emitted when `mouseTracking` is turned on, or when a mouse button is pressed while moving into an item.

### itemPressed

    public final QSignalEmitter.Signal1 itemPressed

  This signal is emitted whenever an item in the table is pressed. The `item` specified is the item that was pressed.

### itemSelectionChanged

    public final QSignalEmitter.Signal0 itemSelectionChanged

  This signal is emitted whenever the selection changes.

See also:
  `selectedItems()`, and isItemSelected().

Constructor Detail

### QTableWidget

    public QTableWidget()

  Creates a new table view with the given `parent`.

### QTableWidget

    public QTableWidget(QWidget parent)

  Creates a new table view with the given `parent`.

### QTableWidget

    public QTableWidget(int rows,
                        int columns)

  Creates a new table view with the given `rows` and `columns`, and with the given `parent`.

### QTableWidget

    public QTableWidget(int rows,
                        int columns,
                        QWidget parent)

  Creates a new table view with the given `rows` and `columns`, and with the given `parent`.

Method Detail

### cellWidget

    public final QWidget cellWidget(int row,
                                    int column)

  Returns the widget displayed in the cell in the given `row` and `column`.

  Note: The table takes ownership of the widget.

See also:
  `setCellWidget()`.

### clear

    public final void clear()

  Removes all items in the view. This will also remove all selections. The table dimensions stay the same.

### clearContents

    public final void clearContents()

  Removes all items not in the headers from the view. This will also remove all selections. The table dimensions stay the same.

### closePersistentEditor

    public final void closePersistentEditor(QTableWidgetItem item)

  Closes the persistent editor for `item`.

See also:
  `openPersistentEditor()`.

### column

    public final int column(QTableWidgetItem item)

  Returns the column for the `item`.

### columnCount

    public final int columnCount()

  This property holds the number of columns in the table.

### currentColumn

    public final int currentColumn()

  Returns the column of the current item.

See also:
  `currentRow()`, and `setCurrentCell()`.

### currentItem

    public final QTableWidgetItem currentItem()

  Returns the current item.

See also:
  `setCurrentItem()`.

### currentRow

    public final int currentRow()

  Returns the row of the current item.

See also:
  `currentColumn()`, and `setCurrentCell()`.

### editItem

    public final void editItem(QTableWidgetItem item)

  Starts editing the `item` if it is editable.

### findItems

    public final java.util.List findItems(java.lang.String text,
                                          Qt.MatchFlag[] flags)

  Finds items that matches the `text` using the given `flags`.

### findItems

    public final java.util.List findItems(java.lang.String text,
                                          Qt.MatchFlags flags)

  Finds items that matches the `text` using the given `flags`.

### horizontalHeaderItem

    public final QTableWidgetItem horizontalHeaderItem(int column)

  Returns the horizontal header item for column, `column`, if one has been set; otherwise returns 0.

See also:
  `setHorizontalHeaderItem()`.

### indexFromItem

    protected final QModelIndex indexFromItem(QTableWidgetItem item)

  Returns the QModelIndex assocated with the given `item`.

### insertColumn

    public final void insertColumn(int column)

  Inserts an empty column into the table at `column`.

### insertRow

    public final void insertRow(int row)

  Inserts an empty row into the table at `row`.

### item

    public final QTableWidgetItem item(int row,
                                       int column)

  Returns the item for the given `row` and `column` if one has been set; otherwise returns 0.

See also:
  `setItem()`.

### itemAt

    public final QTableWidgetItem itemAt(QPoint p)

  Returns a pointer to the item at the given `point`, or returns 0 if the point is not covered by an item in the table widget.

See also:
  `item()`.

### itemAt

    public final QTableWidgetItem itemAt(int x,
                                         int y)

  Returns the item at the position equivalent to `QPoint`(`ax`, `ay`) in the table widget's coordinate system, or returns 0 if the specified point is not covered by an item in the table widget.

See also:
  `item()`.

### itemFromIndex

    protected final QTableWidgetItem itemFromIndex(QModelIndex index)

  Returns a pointer to the `QTableWidgetItem` assocated with the given `index`.

### itemPrototype

    public final QTableWidgetItem itemPrototype()

  Returns the item prototype used by the table.

See also:
  `setItemPrototype()`.

### items

    protected final java.util.List items(QMimeData data)

  Returns a list of pointers to the items contained in the `data` object. If the object was not created by a `QTreeWidget` in the same process, the list is empty.

### openPersistentEditor

    public final void openPersistentEditor(QTableWidgetItem item)

  Opens an editor for the give `item`. The editor remains open after editing.

See also:
  `closePersistentEditor()`.

### removeCellWidget

    public final void removeCellWidget(int row,
                                       int column)

  Removes the widget set on the cell indicated by `row` and `column`.

### removeColumn

    public final void removeColumn(int column)

  Removes the column `column` and all its items from the table.

### removeRow

    public final void removeRow(int row)

  Removes the row `row` and all its items from the table.

### row

    public final int row(QTableWidgetItem item)

  Returns the row for the `item`.

### rowCount

    public final int rowCount()

  This property holds the number of rows in the table.

### scrollToItem

    public final void scrollToItem(QTableWidgetItem item)

  Scrolls the view if necessary to ensure that the `item` is visible. The `hint` parameter specifies more precisely where the `item` should be located after the operation.

### scrollToItem

    public final void scrollToItem(QTableWidgetItem item,
                                   QAbstractItemView.ScrollHint hint)

  Scrolls the view if necessary to ensure that the `item` is visible. The `hint` parameter specifies more precisely where the `item` should be located after the operation.

### selectedItems

    public final java.util.List selectedItems()

  Returns a list of all selected items.

  This function returns a list of pointers to the contents of the selected cells. Use the `selectedIndexes()` function to retrieve the complete selection including empty cells.

See also:
  `selectedIndexes()`.

### selectedRanges

    public final java.util.List selectedRanges()

  Returns a list of all selected ranges.

See also:
  `QTableWidgetSelectionRange`.

### setCellWidget

    public final void setCellWidget(int row,
                                    int column,
                                    QWidget widget)

  Sets the `widget` to be displayed in the cell in the given `row` and `column`.

  Note: The table takes ownership of the widget.

See also:
  `cellWidget()`.

### setColumnCount

    public final void setColumnCount(int columns)

  This property holds the number of columns in the table.

### setCurrentCell

    public final void setCurrentCell(int row,
                                     int column)

  Sets the current cell to be the cell at position (`row`, `column`).

  Depending on the current `selection mode` , the cell may also be selected.

See also:
  `setCurrentItem()`, `currentRow()`, and `currentColumn()`.

### setCurrentCell

    public final void setCurrentCell(int row,
                                     int column,
                                     QItemSelectionModel.SelectionFlag[] command)

  Sets the current cell to be the cell at position (`row`, `column`), using the given `command`.

See also:
  `setCurrentItem()`, `currentRow()`, and `currentColumn()`.

### setCurrentCell

    public final void setCurrentCell(int row,
                                     int column,
                                     QItemSelectionModel.SelectionFlags command)

  Sets the current cell to be the cell at position (`row`, `column`), using the given `command`.

See also:
  `setCurrentItem()`, `currentRow()`, and `currentColumn()`.

### setCurrentItem

    public final void setCurrentItem(QTableWidgetItem item)

  Sets the current item to `item`.

  Depending on the current `selection mode` , the item may also be selected.

See also:
  `currentItem()`, and `setCurrentCell()`.

### setCurrentItem

    public final void setCurrentItem(QTableWidgetItem item,
                                     QItemSelectionModel.SelectionFlag[] command)

  Sets the current item to be `item`, using the given `command`.

See also:
  `currentItem()`, and `setCurrentCell()`.

### setCurrentItem

    public final void setCurrentItem(QTableWidgetItem item,
                                     QItemSelectionModel.SelectionFlags command)

  Sets the current item to be `item`, using the given `command`.

See also:
  `currentItem()`, and `setCurrentCell()`.

### setHorizontalHeaderItem

    public final void setHorizontalHeaderItem(int column,
                                              QTableWidgetItem item)

  Sets the horizontal header item for column `column` to `item`.

See also:
  `horizontalHeaderItem()`.

### setHorizontalHeaderLabels

    public final void setHorizontalHeaderLabels(java.util.List labels)

  Sets the horizontal header labels using `labels`.

### setItem

    public final void setItem(int row,
                              int column,
                              QTableWidgetItem item)

  Sets the item for the given `row` and `column` to `item`.

  The table takes ownership of the item.

  Note that if sorting is enabled (see `sortingEnabled`) and `column` is the current sort column, the `row` will be moved to the sorted position determined by `item`.

  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 `row` argument for all items in the same row (i.e. `setItem()` will not move the row).

See also:
  `item()`, and `takeItem()`.

### setItemPrototype

    public final void setItemPrototype(QTableWidgetItem item)

  Sets the item prototype for the table to the specified `item`.

  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 editing in an empty cell. This is useful when you have a `QTableWidgetItem` subclass and want to make sure that `QTableWidget` creates instances of your subclass.

  The table takes ownership of the prototype.

See also:
  `itemPrototype()`.

### setRangeSelected

    public final void setRangeSelected(QTableWidgetSelectionRange range,
                                       boolean select)

  Selects or deselects the `range` depending on `select`.

### setRowCount

    public final void setRowCount(int rows)

  This property holds the number of rows in the table.

### setVerticalHeaderItem

    public final void setVerticalHeaderItem(int row,
                                            QTableWidgetItem item)

  Sets the vertical header item for row `row` to `item`.

See also:
  `verticalHeaderItem()`.

### setVerticalHeaderLabels

    public final void setVerticalHeaderLabels(java.util.List labels)

  Sets the vertical header labels using `labels`.

### sortItems

    public final void sortItems(int column)

  Sorts all the rows in the table widget based on `column` and `order`.

### sortItems

    public final void sortItems(int column,
                                Qt.SortOrder order)

  Sorts all the rows in the table widget based on `column` and `order`.

### takeHorizontalHeaderItem

    public final QTableWidgetItem takeHorizontalHeaderItem(int column)

  Removes the horizontal header item at `column` from the header without deleting it.

### takeItem

    public final QTableWidgetItem takeItem(int row,
                                           int column)

  Removes the item at `row` and `column` from the table without deleting it.

### takeVerticalHeaderItem

    public final QTableWidgetItem takeVerticalHeaderItem(int row)

  Removes the vertical header item at `row` from the header without deleting it.

### verticalHeaderItem

    public final QTableWidgetItem verticalHeaderItem(int row)

  Returns the vertical header item for row `row`.

See also:
  `setVerticalHeaderItem()`.

### visualColumn

    public final int visualColumn(int logicalColumn)

  Returns the visual column of the given `logicalColumn`.

### visualItemRect

    public final QRect visualItemRect(QTableWidgetItem item)

  Returns the rectangle on the viewport occupied by the item at `item`.

### visualRow

    public final int visualRow(int logicalRow)

  Returns the visual row of the given `logicalRow`.

### dropMimeData

    protected boolean dropMimeData(int row,
                                   int column,
                                   QMimeData data,
                                   Qt.DropAction action)

  Handles the `data` supplied by a drag and drop operation that ended with the given `action` in the given `row` and `column`. Returns true if the data and action can be handled by the model; otherwise returns false.

See also:
  `supportedDropActions()`.

### mimeData

    protected QMimeData mimeData(java.util.List items)

  Returns an object that contains a serialized description of the specified `items`. The format used to describe the items is obtained from the `mimeTypes()` function.

  If the list of items is empty, 0 is returned rather than a serialized empty list.

### mimeTypes

    protected java.util.List mimeTypes()

  Returns a list of MIME types that can be used to describe a list of tablewidget items.

See also:
  `mimeData()`.

### supportedDropActions

    protected Qt.DropActions supportedDropActions()

  Returns the drop actions supported by this view.

See also:
  Qt::DropActions.

### fromNativePointer

    public static QTableWidget fromNativePointer(QNativePointer nativePointer)

  This method returns the QTableWidget instance pointed to by `nativePointer`.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD