Qt Jambi Home

com.trolltech.qt.gui
Class QTableWidget

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.core.QObject
              extended by com.trolltech.qt.gui.QWidget
                  extended by com.trolltech.qt.gui.QFrame
                      extended by com.trolltech.qt.gui.QAbstractScrollArea
                          extended by com.trolltech.qt.gui.QAbstractItemView
                              extended by com.trolltech.qt.gui.QTableView
                                  extended by 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(tr("%1").arg(
            (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(QIcon(QPixmap(":/Images/cubed.png")));
        cubesHeaderItem->setTextAlignment(Qt::AlignVCenter);

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.

Screenshot of a Windows XP style table widgetScreenshot of a Macintosh style table widgetScreenshot of a Plastique style table widget
A Windows XP style table widget.A Macintosh style table widget.A Plastique style table widget.

See Also:
QTableWidgetItem, QTableView, 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.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>
 
Field Summary
 QSignalEmitter.Signal2<java.lang.Integer,java.lang.Integer> cellActivated
          This signal is emitted when the cell specified by row and column has been activated Compatible Slot Signatures: void mySlot(int row, int column) void mySlot(int row) void mySlot()
 QSignalEmitter.Signal2<java.lang.Integer,java.lang.Integer> cellChanged
          This signal is emitted whenever the data of the item in the cell specified by row and column has changed.
 QSignalEmitter.Signal2<java.lang.Integer,java.lang.Integer> cellClicked
          This signal is emitted whenever a cell in the table is clicked.
 QSignalEmitter.Signal2<java.lang.Integer,java.lang.Integer> cellDoubleClicked
          This signal is emitted whenever a cell in the table is double clicked.
 QSignalEmitter.Signal2<java.lang.Integer,java.lang.Integer> cellEntered
          This signal is emitted when the mouse cursor enters a cell.
 QSignalEmitter.Signal2<java.lang.Integer,java.lang.Integer> cellPressed
          This signal is emitted whenever a cell the table is pressed.
 QSignalEmitter.Signal4<java.lang.Integer,java.lang.Integer,java.lang.Integer,java.lang.Integer> currentCellChanged
          This signal is emitted whenever the current cell changes.
 QSignalEmitter.Signal2<QTableWidgetItem,QTableWidgetItem> currentItemChanged
          This signal is emitted whenever the current item changes.
 QSignalEmitter.Signal1<QTableWidgetItem> itemActivated
          This signal is emitted when the specified item has been activated Compatible Slot Signatures: void mySlot(com.trolltech.qt.gui.QTableWidgetItem item) void mySlot()
 QSignalEmitter.Signal1<QTableWidgetItem> itemChanged
          This signal is emitted whenever the data of item has changed.
 QSignalEmitter.Signal1<QTableWidgetItem> itemClicked
          This signal is emitted whenever an item in the table is clicked.
 QSignalEmitter.Signal1<QTableWidgetItem> itemDoubleClicked
          This signal is emitted whenever an item in the table is double clicked.
 QSignalEmitter.Signal1<QTableWidgetItem> itemEntered
          This signal is emitted when the mouse cursor enters an item.
 QSignalEmitter.Signal1<QTableWidgetItem> 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()
          Equivalent to QTableWidget(0).
QTableWidget(int rows, int columns)
          Equivalent to QTableWidget(rows, columns, 0).
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()
          Returns 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  void dropEvent(QDropEvent event)
          This function is reimplemented for internal reasons.
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.
 boolean event(QEvent e)
          This function is reimplemented for internal reasons.
 java.util.List<QTableWidgetItem> findItems(java.lang.String text, Qt.MatchFlag... flags)
          Finds items that matches the text using the given flags.
 java.util.List<QTableWidgetItem> findItems(java.lang.String text, Qt.MatchFlags flags)
          Finds items that matches the text using the given flags.
static QTableWidget fromNativePointer(QNativePointer nativePointer)
          This function returns the QTableWidget instance pointed to by nativePointer
 QTableWidgetItem horizontalHeaderItem(int column)
          Returns the horizontal header item for column column.
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(x, y) 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 p, 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<QTableWidgetItem> items(QMimeData data)
          Returns a list of pointers to the items contained in the data object.
protected  QMimeData mimeData(java.util.List<QTableWidgetItem> items)
          Returns an object that contains a serialized description of the specified items.
protected  java.util.List<java.lang.String> 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()
          Returns the number of rows in the table.
 void scrollToItem(QTableWidgetItem item)
          Equivalent to scrollToItem(item, EnsureVisible).
 void scrollToItem(QTableWidgetItem item, QAbstractItemView.ScrollHint hint)
          Scrolls the view if necessary to ensure that the item is visible.
 java.util.List<QTableWidgetItem> selectedItems()
          Returns a list of all selected items.
 java.util.List<QTableWidgetSelectionRange> 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)
          Sets the number of columns in the table to columns.
 void setCurrentCell(int row, int column)
          Sets the current cell to be the cell at position (row, column).
 void setCurrentItem(QTableWidgetItem item)
          Sets the current item to item.
 void setHorizontalHeaderItem(int column, QTableWidgetItem item)
          Sets the horizontal header item for column column to item.
 void setHorizontalHeaderLabels(java.util.List<java.lang.String> 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 setModel(QAbstractItemModel model)
          Deprecated. 
 void setRangeSelected(QTableWidgetSelectionRange range, boolean select)
          Selects or deselects the range depending on select.
 void setRowCount(int rows)
          Sets the number of rows in the table to rows.
 void setVerticalHeaderItem(int row, QTableWidgetItem item)
          Sets the vertical header item for row row to item.
 void setVerticalHeaderLabels(java.util.List<java.lang.String> labels)
          Sets the vertical header labels using labels.
 void sortItems(int column)
          Equivalent to sortItems(column, Qt::AscendingOrder).
 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
columnAt, columnCountChanged, columnMoved, columnResized, columnSpan, columnViewportPosition, columnWidth, currentChanged, gridStyle, hideColumn, hideRow, horizontalHeader, horizontalOffset, horizontalScrollbarAction, indexAt, isColumnHidden, isCornerButtonEnabled, isIndexHidden, isRowHidden, isSortingEnabled, moveCursor, paintEvent, resizeColumnsToContents, resizeColumnToContents, resizeRowsToContents, resizeRowToContents, rowAt, rowCountChanged, rowHeight, rowMoved, rowResized, rowSpan, rowViewportPosition, scrollContentsBy, scrollTo, selectColumn, selectedIndexes, selectionChanged, selectRow, setColumnHidden, setColumnWidth, setCornerButtonEnabled, setGridStyle, setHorizontalHeader, setRootIndex, setRowHeight, setRowHidden, setSelection, setSelectionModel, setShowGrid, setSortingEnabled, setSpan, setVerticalHeader, setWordWrap, showColumn, showGrid, showRow, sizeHintForColumn, sizeHintForRow, sortByColumn, timerEvent, updateGeometries, verticalHeader, verticalOffset, verticalScrollbarAction, viewOptions, visualRect, visualRegionForSelection, wordWrap
 
Methods inherited from class com.trolltech.qt.gui.QAbstractItemView
alternatingRowColors, clearSelection, closeEditor, closePersistentEditor, commitData, currentIndex, dataChanged, dirtyRegionOffset, doAutoScroll, doItemsLayout, dragDropMode, dragDropOverwriteMode, dragEnabled, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropIndicatorPosition, edit, edit, editorDestroyed, editTriggers, executeDelayedItemsLayout, focusInEvent, focusNextPrevChild, focusOutEvent, hasAutoScroll, horizontalScrollbarValueChanged, horizontalScrollMode, iconSize, indexWidget, inputMethodEvent, inputMethodQuery, itemDelegate, itemDelegate, itemDelegateForColumn, itemDelegateForRow, keyboardSearch, keyPressEvent, model, mouseDoubleClickEvent, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, openPersistentEditor, reset, resizeEvent, rootIndex, rowsAboutToBeRemoved, rowsInserted, scheduleDelayedItemsLayout, scrollDirtyRegion, scrollTo, scrollToBottom, scrollToTop, selectAll, selectionBehavior, selectionCommand, selectionCommand, selectionMode, selectionModel, setAlternatingRowColors, setAutoScroll, setCurrentIndex, setDirtyRegion, setDragDropMode, setDragDropOverwriteMode, setDragEnabled, setDropIndicatorShown, setEditTriggers, setEditTriggers, setHorizontalScrollMode, setIconSize, setIndexWidget, setItemDelegate, setItemDelegateForColumn, setItemDelegateForRow, setSelectionBehavior, setSelectionMode, setState, setTabKeyNavigation, setTextElideMode, setVerticalScrollMode, showDropIndicator, sizeHintForIndex, startAutoScroll, startDrag, startDrag, state, stopAutoScroll, tabKeyNavigation, textElideMode, update, updateEditorData, updateEditorGeometries, verticalScrollbarValueChanged, verticalScrollMode, viewportEvent
 
Methods inherited from class com.trolltech.qt.gui.QAbstractScrollArea
addScrollBarWidget, addScrollBarWidget, contextMenuEvent, cornerWidget, horizontalScrollBar, horizontalScrollBarPolicy, maximumViewportSize, minimumSizeHint, paintEngine, scrollBarWidgets, scrollBarWidgets, setCornerWidget, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setupViewport, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportMargins, sizeHint, verticalScrollBar, verticalScrollBarPolicy, viewport, wheelEvent
 
Methods inherited from class com.trolltech.qt.gui.QFrame
changeEvent, drawFrame, 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, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuPolicy, createWinId, cursor, depth, destroy, destroy, destroy, devType, ensurePolished, enterEvent, focusNextChild, 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, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isLeftToRight, isMaximized, isMinimized, isModal, isRightToLeft, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyReleaseEvent, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumWidth, mouseGrabber, move, move, moveEvent, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, overrideWindowState, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, 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, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, width, widthMM, window, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y
 
Methods inherited from class com.trolltech.qt.core.QObject
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread
 
Methods inherited from class com.trolltech.qt.QtJambiObject
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr
 
Methods inherited from class com.trolltech.qt.QSignalEmitter
disconnect, disconnect, signalSender
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.trolltech.qt.QtJambiInterface
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership
 

Field Detail

cellActivated

public final QSignalEmitter.Signal2<java.lang.Integer,java.lang.Integer> cellActivated

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

Compatible Slot Signatures:
void mySlot(int row, int column)
void mySlot(int row)
void mySlot()


cellChanged

public final QSignalEmitter.Signal2<java.lang.Integer,java.lang.Integer> cellChanged

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

Compatible Slot Signatures:
void mySlot(int row, int column)
void mySlot(int row)
void mySlot()


cellClicked

public final QSignalEmitter.Signal2<java.lang.Integer,java.lang.Integer> cellClicked

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

Compatible Slot Signatures:
void mySlot(int row, int column)
void mySlot(int row)
void mySlot()


cellDoubleClicked

public final QSignalEmitter.Signal2<java.lang.Integer,java.lang.Integer> 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.

Compatible Slot Signatures:
void mySlot(int row, int column)
void mySlot(int row)
void mySlot()


cellEntered

public final QSignalEmitter.Signal2<java.lang.Integer,java.lang.Integer> 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.

Compatible Slot Signatures:
void mySlot(int row, int column)
void mySlot(int row)
void mySlot()


cellPressed

public final QSignalEmitter.Signal2<java.lang.Integer,java.lang.Integer> cellPressed

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

Compatible Slot Signatures:
void mySlot(int row, int column)
void mySlot(int row)
void mySlot()


currentCellChanged

public final QSignalEmitter.Signal4<java.lang.Integer,java.lang.Integer,java.lang.Integer,java.lang.Integer> 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.

Compatible Slot Signatures:
void mySlot(int currentRow, int currentColumn, int previousRow, int previousColumn)
void mySlot(int currentRow, int currentColumn, int previousRow)
void mySlot(int currentRow, int currentColumn)
void mySlot(int currentRow)
void mySlot()


currentItemChanged

public final QSignalEmitter.Signal2<QTableWidgetItem,QTableWidgetItem> 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.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QTableWidgetItem current, com.trolltech.qt.gui.QTableWidgetItem previous)
void mySlot(com.trolltech.qt.gui.QTableWidgetItem current)
void mySlot()


itemActivated

public final QSignalEmitter.Signal1<QTableWidgetItem> itemActivated

This signal is emitted when the specified item has been activated

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QTableWidgetItem item)
void mySlot()


itemChanged

public final QSignalEmitter.Signal1<QTableWidgetItem> itemChanged

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

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QTableWidgetItem item)
void mySlot()


itemClicked

public final QSignalEmitter.Signal1<QTableWidgetItem> itemClicked

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

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QTableWidgetItem item)
void mySlot()


itemDoubleClicked

public final QSignalEmitter.Signal1<QTableWidgetItem> itemDoubleClicked

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

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QTableWidgetItem item)
void mySlot()


itemEntered

public final QSignalEmitter.Signal1<QTableWidgetItem> 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.

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QTableWidgetItem item)
void mySlot()


itemPressed

public final QSignalEmitter.Signal1<QTableWidgetItem> itemPressed

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

Compatible Slot Signatures:
void mySlot(com.trolltech.qt.gui.QTableWidgetItem item)
void mySlot()


itemSelectionChanged

public final QSignalEmitter.Signal0 itemSelectionChanged

This signal is emitted whenever the selection changes.

Compatible Slot Signature:
void mySlot()
See Also:
selectedItems, isItemSelected

Constructor Detail

QTableWidget

public QTableWidget()

Equivalent to QTableWidget(0).


QTableWidget

public QTableWidget(QWidget parent)

Creates a new table view with the given parent.


QTableWidget

public QTableWidget(int rows,
                    int columns)

Equivalent to QTableWidget(rows, columns, 0).


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.

See Also:
setCellWidget

clear

public final void clear()

Removes all items in the view. This will also remove all selections. The table dimentions 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()

Returns the number of columns in the table.

See Also:
setColumnCount

currentColumn

public final int currentColumn()

Returns the column of the current item.

See Also:
currentRow, 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, setCurrentCell

editItem

public final void editItem(QTableWidgetItem item)

Starts editing the item if it is editable.


findItems

public final java.util.List<QTableWidgetItem> findItems(java.lang.String text,
                                                        Qt.MatchFlag... flags)

Finds items that matches the text using the given flags.


findItems

public final java.util.List<QTableWidgetItem> 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.

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 p, 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(x, y) 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<QTableWidgetItem> 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()

Returns the number of rows in the table.

See Also:
setRowCount

scrollToItem

public final void scrollToItem(QTableWidgetItem item)

Equivalent to scrollToItem(item, EnsureVisible).


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<QTableWidgetItem> 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<QTableWidgetSelectionRange> 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.

See Also:
cellWidget

setColumnCount

public final void setColumnCount(int columns)

Sets the number of columns in the table to columns.

See Also:
columnCount

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, 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, 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<java.lang.String> 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, 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

setModel

@Deprecated
public final void setModel(QAbstractItemModel model)
Deprecated. 

This function is reimplemented for internal reasons.

Overrides:
setModel in class QTableView
See Also:
model, selectionModel, setSelectionModel

setRangeSelected

public final void setRangeSelected(QTableWidgetSelectionRange range,
                                   boolean select)

Selects or deselects the range depending on select.


setRowCount

public final void setRowCount(int rows)

Sets the number of rows in the table to rows.

See Also:
rowCount

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<java.lang.String> labels)

Sets the vertical header labels using labels.


sortItems

public final void sortItems(int column)

Equivalent to sortItems(column, Qt::AscendingOrder).


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.


dropEvent

protected void dropEvent(QDropEvent event)

This function is reimplemented for internal reasons.

Overrides:
dropEvent in class QAbstractItemView
See Also:
startDrag

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

event

public boolean event(QEvent e)

This function is reimplemented for internal reasons.

Overrides:
event in class QAbstractItemView
See Also:
QEvent::type

mimeData

protected QMimeData mimeData(java.util.List<QTableWidgetItem> 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<java.lang.String> 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 function returns the QTableWidget instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

Qt Jambi Home