CopperSpice API  1.9.2
QTableWidget Class Reference

The QTableWidget class provides an item-based table view with a default model. More...

Inheritance diagram for QTableWidget:
QTableView QAbstractItemView QAbstractScrollArea QFrame QWidget QObject QPaintDevice

Public Signals

void cellActivated (int row, int column)
 
void cellChanged (int row, int column)
 
void cellClicked (int row, int column)
 
void cellDoubleClicked (int row, int column)
 
void cellEntered (int row, int column)
 
void cellPressed (int row, int column)
 
void currentCellChanged (int currentRow, int currentColumn, int previousRow, int previousColumn)
 
void currentItemChanged (QTableWidgetItem *current, QTableWidgetItem *previous)
 
void itemActivated (QTableWidgetItem *item)
 
void itemChanged (QTableWidgetItem *item)
 
void itemClicked (QTableWidgetItem *item)
 
void itemDoubleClicked (QTableWidgetItem *item)
 
void itemEntered (QTableWidgetItem *item)
 
void itemPressed (QTableWidgetItem *item)
 
void itemSelectionChanged ()
 
- Public Signals inherited from QAbstractItemView
void activated (const QModelIndex &index)
 
void clicked (const QModelIndex &index)
 
void doubleClicked (const QModelIndex &index)
 
void entered (const QModelIndex &index)
 
void iconSizeChanged (const QSize &size)
 
void pressed (const QModelIndex &index)
 
void viewportEntered ()
 
- Public Signals inherited from QWidget
void customContextMenuRequested (const QPoint &pos)
 
void windowIconChanged (const QIcon &icon)
 
void windowIconTextChanged (const QString &iconText)
 
void windowTitleChanged (const QString &title)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Slots

void clear ()
 
void clearContents ()
 
void insertColumn (int column)
 
void insertRow (int row)
 
void removeColumn (int column)
 
void removeRow (int row)
 
void scrollToItem (const QTableWidgetItem *item, QAbstractItemView::ScrollHint hint=EnsureVisible)
 
- Public Slots inherited from QTableView
void hideColumn (int column)
 
void hideRow (int row)
 
void resizeColumnsToContents ()
 
void resizeColumnToContents (int column)
 
void resizeRowsToContents ()
 
void resizeRowToContents (int row)
 
void selectColumn (int column)
 
void selectRow (int row)
 
void setShowGrid (bool show)
 
void showColumn (int column)
 
void showRow (int row)
 
void sortByColumn (int column)
 
- Public Slots inherited from QAbstractItemView
void clearSelection ()
 
void edit (const QModelIndex &index)
 
virtual void reset ()
 
void scrollToBottom ()
 
void scrollToTop ()
 
virtual void selectAll ()
 
void setCurrentIndex (const QModelIndex &index)
 
virtual void setRootIndex (const QModelIndex &index)
 
void update (const QModelIndex &index)
 
- Public Slots inherited from QWidget
bool close ()
 
void hide ()
 
void lower ()
 
void raise ()
 
void repaint ()
 
void setDisabled (bool disable)
 
void setEnabled (bool enable)
 
void setFocus ()
 
void setHidden (bool hidden)
 
void setStyleSheet (const QString &styleSheet)
 
virtual void setVisible (bool visible)
 
void setWindowModified (bool modified)
 
void setWindowTitle (const QString &title)
 
void show ()
 
void showFullScreen ()
 
void showMaximized ()
 
void showMinimized ()
 
void showNormal ()
 
void update ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Public Methods

 QTableWidget (int rows, int columns, QWidget *parent=nullptr)
 
 QTableWidget (QWidget *parent=nullptr)
 
 ~QTableWidget ()
 
QWidgetcellWidget (int row, int column) const
 
void closePersistentEditor (QTableWidgetItem *item)
 
int column (const QTableWidgetItem *item) const
 
int columnCount () const
 
int currentColumn () const
 
QTableWidgetItemcurrentItem () const
 
int currentRow () const
 
void editItem (QTableWidgetItem *item)
 
QList< QTableWidgetItem * > findItems (const QString &text, Qt::MatchFlags flags) const
 
QTableWidgetItemhorizontalHeaderItem (int column) const
 
bool isItemSelected (const QTableWidgetItem *item) const
 
bool isSortingEnabled () const
 
QTableWidgetItemitem (int row, int column) const
 
QTableWidgetItemitemAt (const QPoint &point) const
 
QTableWidgetItemitemAt (int x, int y) const
 
const QTableWidgetItemitemPrototype () const
 
void openPersistentEditor (QTableWidgetItem *item)
 
void removeCellWidget (int row, int column)
 
int row (const QTableWidgetItem *item) const
 
int rowCount () const
 
QList< QTableWidgetItem * > selectedItems () const
 
QList< QTableWidgetSelectionRangeselectedRanges () const
 
void setCellWidget (int row, int column, QWidget *widget)
 
void setColumnCount (int columns)
 
void setCurrentCell (int row, int column)
 
void setCurrentCell (int row, int column, QItemSelectionModel::SelectionFlags command)
 
void setCurrentItem (QTableWidgetItem *item)
 
void setCurrentItem (QTableWidgetItem *item, QItemSelectionModel::SelectionFlags command)
 
void setHorizontalHeaderItem (int column, QTableWidgetItem *item)
 
void setHorizontalHeaderLabels (const QStringList &labels)
 
void setItem (int row, int column, QTableWidgetItem *item)
 
void setItemPrototype (const QTableWidgetItem *item)
 
void setItemSelected (const QTableWidgetItem *item, bool select)
 
void setRangeSelected (const QTableWidgetSelectionRange &range, bool select)
 
void setRowCount (int rows)
 
void setSortingEnabled (bool enable)
 
void setVerticalHeaderItem (int row, QTableWidgetItem *item)
 
void setVerticalHeaderLabels (const QStringList &labels)
 
void sortItems (int column, Qt::SortOrder order=Qt::AscendingOrder)
 
QTableWidgetItemtakeHorizontalHeaderItem (int column)
 
QTableWidgetItemtakeItem (int row, int column)
 
QTableWidgetItemtakeVerticalHeaderItem (int row)
 
QTableWidgetItemverticalHeaderItem (int row) const
 
int visualColumn (int logicalColumn) const
 
QRect visualItemRect (const QTableWidgetItem *item) const
 
int visualRow (int logicalRow) const
 
- Public Methods inherited from QTableView
 QTableView (QWidget *parent=nullptr)
 
 ~QTableView ()
 
void clearSpans ()
 
int columnAt (int x) const
 
int columnSpan (int row, int column) const
 
int columnViewportPosition (int column) const
 
int columnWidth (int column) const
 
Qt::PenStyle gridStyle () const
 
QHeaderViewhorizontalHeader () const
 
QModelIndex indexAt (const QPoint &pos) const override
 
bool isColumnHidden (int column) const
 
bool isCornerButtonEnabled () const
 
bool isRowHidden (int row) const
 
bool isSortingEnabled () const
 
int rowAt (int y) const
 
int rowHeight (int row) const
 
int rowSpan (int row, int column) const
 
int rowViewportPosition (int row) const
 
void scrollTo (const QModelIndex &index, ScrollHint hint=EnsureVisible) override
 
void setColumnHidden (int column, bool hide)
 
void setColumnWidth (int column, int width)
 
void setCornerButtonEnabled (bool enable)
 
void setGridStyle (Qt::PenStyle style)
 
void setHorizontalHeader (QHeaderView *header)
 
void setRootIndex (const QModelIndex &index) override
 
void setRowHeight (int row, int height)
 
void setRowHidden (int row, bool hide)
 
void setSelectionModel (QItemSelectionModel *selectionModel) override
 
void setSortingEnabled (bool enable)
 
void setSpan (int row, int column, int rowSpanCount, int columnSpanCount)
 
void setVerticalHeader (QHeaderView *header)
 
void setWordWrap (bool on)
 
bool showGrid () const
 
void sortByColumn (int column, Qt::SortOrder order)
 
QHeaderViewverticalHeader () const
 
QRect visualRect (const QModelIndex &index) const override
 
bool wordWrap () const
 
- Public Methods inherited from QAbstractItemView
 QAbstractItemView (QWidget *parent=nullptr)
 
 ~QAbstractItemView ()
 
bool alternatingRowColors () const
 
int autoScrollMargin () const
 
void closePersistentEditor (const QModelIndex &index)
 
QModelIndex currentIndex () const
 
Qt::DropAction defaultDropAction () const
 
DragDropMode dragDropMode () const
 
bool dragDropOverwriteMode () const
 
bool dragEnabled () const
 
EditTriggers editTriggers () const
 
bool hasAutoScroll () const
 
ScrollMode horizontalScrollMode () const
 
QSize iconSize () const
 
QWidgetindexWidget (const QModelIndex &index) const
 
QVariant inputMethodQuery (Qt::InputMethodQuery query) const override
 
QAbstractItemDelegateitemDelegate () const
 
QAbstractItemDelegateitemDelegate (const QModelIndex &index) const
 
QAbstractItemDelegateitemDelegateForColumn (int column) const
 
QAbstractItemDelegateitemDelegateForRow (int row) const
 
virtual void keyboardSearch (const QString &search)
 
QAbstractItemModelmodel () const
 
void openPersistentEditor (const QModelIndex &index)
 
QModelIndex rootIndex () const
 
QAbstractItemView::SelectionBehavior selectionBehavior () const
 
QAbstractItemView::SelectionMode selectionMode () const
 
QItemSelectionModelselectionModel () const
 
void setAlternatingRowColors (bool enable)
 
void setAutoScroll (bool enable)
 
void setAutoScrollMargin (int margin)
 
void setDefaultDropAction (Qt::DropAction dropAction)
 
void setDragDropMode (DragDropMode behavior)
 
void setDragDropOverwriteMode (bool overwrite)
 
void setDragEnabled (bool enable)
 
void setDropIndicatorShown (bool enable)
 
void setEditTriggers (EditTriggers triggers)
 
void setHorizontalScrollMode (ScrollMode mode)
 
void setIconSize (const QSize &size)
 
void setIndexWidget (const QModelIndex &index, QWidget *widget)
 
void setItemDelegate (QAbstractItemDelegate *delegate)
 
void setItemDelegateForColumn (int column, QAbstractItemDelegate *delegate)
 
void setItemDelegateForRow (int row, QAbstractItemDelegate *delegate)
 
void setSelectionBehavior (QAbstractItemView::SelectionBehavior behavior)
 
void setSelectionMode (QAbstractItemView::SelectionMode mode)
 
void setTabKeyNavigation (bool enable)
 
void setTextElideMode (Qt::TextElideMode mode)
 
void setVerticalScrollMode (ScrollMode mode)
 
bool showDropIndicator () const
 
QSize sizeHintForIndex (const QModelIndex &index) const
 
bool tabKeyNavigation () const
 
Qt::TextElideMode textElideMode () const
 
ScrollMode verticalScrollMode () const
 
- Public Methods inherited from QAbstractScrollArea
 QAbstractScrollArea (QWidget *parent=nullptr)
 
 ~QAbstractScrollArea ()
 
void addScrollBarWidget (QWidget *widget, Qt::Alignment alignment)
 
QWidgetcornerWidget () const
 
QScrollBarhorizontalScrollBar () const
 
Qt::ScrollBarPolicy horizontalScrollBarPolicy () const
 
QSize maximumViewportSize () const
 
QSize minimumSizeHint () const override
 
QWidgetList scrollBarWidgets (Qt::Alignment alignment)
 
void setCornerWidget (QWidget *widget)
 
void setHorizontalScrollBar (QScrollBar *scrollBar)
 
void setHorizontalScrollBarPolicy (Qt::ScrollBarPolicy policy)
 
void setSizeAdjustPolicy (SizeAdjustPolicy policy)
 
virtual void setupViewport (QWidget *viewport)
 
void setVerticalScrollBar (QScrollBar *scrollBar)
 
void setVerticalScrollBarPolicy (Qt::ScrollBarPolicy policy)
 
void setViewport (QWidget *widget)
 
SizeAdjustPolicy sizeAdjustPolicy () const
 
QSize sizeHint () const override
 
QScrollBarverticalScrollBar () const
 
Qt::ScrollBarPolicy verticalScrollBarPolicy () const
 
QWidgetviewport () const
 
- Public Methods inherited from QFrame
 QFrame (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag)
 
 ~QFrame ()
 
QRect frameRect () const
 
Shadow frameShadow () const
 
Shape frameShape () const
 
int frameStyle () const
 
int frameWidth () const
 
int lineWidth () const
 
int midLineWidth () const
 
void setFrameRect (const QRect &rect)
 
void setFrameShadow (Shadow value)
 
void setFrameShape (Shape value)
 
void setFrameStyle (int style)
 
void setLineWidth (int width)
 
void setMidLineWidth (int width)
 
QSize sizeHint () const override
 
- Public Methods inherited from QWidget
 QWidget (QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag)
 
 ~QWidget ()
 
bool acceptDrops () const
 
QString accessibleDescription () const
 
QString accessibleName () const
 
QList< QAction * > actions () const
 
void activateWindow ()
 
void addAction (QAction *action)
 
void addActions (const QList< QAction * > &actions)
 
void adjustSize ()
 
bool autoFillBackground () const
 
QPalette::ColorRole backgroundRole () const
 
QBackingStorebackingStore () const
 
QSize baseSize () const
 
QWidget * childAt (const QPoint &position) const
 
QWidget * childAt (int x, int y) const
 
QRect childrenRect () const
 
QRegion childrenRegion () const
 
void clearFocus ()
 
void clearMask ()
 
QMargins contentsMargins () const
 
QRect contentsRect () const
 
Qt::ContextMenuPolicy contextMenuPolicy () const
 
QCursor cursor () const
 
WId effectiveWinId () const
 
void ensurePolished () const
 
Qt::FocusPolicy focusPolicy () const
 
QWidget * focusProxy () const
 
QWidget * focusWidget () const
 
const QFontfont () const
 
QFontInfo fontInfo () const
 
QFontMetrics fontMetrics () const
 
QPalette::ColorRole foregroundRole () const
 
QRect frameGeometry () const
 
QSize frameSize () const
 
const QRectgeometry () const
 
void getContentsMargins (int *left, int *top, int *right, int *bottom) const
 
QPixmap grab (const QRect &rectangle=QRect (QPoint (0, 0), QSize (-1,-1)))
 
void grabGesture (Qt::GestureType gestureType, Qt::GestureFlags flags=Qt::GestureFlags ())
 
void grabKeyboard ()
 
void grabMouse ()
 
void grabMouse (const QCursor &cursor)
 
int grabShortcut (const QKeySequence &key, Qt::ShortcutContext context=Qt::WindowShortcut)
 
QGraphicsEffectgraphicsEffect () const
 
QGraphicsProxyWidgetgraphicsProxyWidget () const
 
bool hasEditFocus () const
 
bool hasFocus () const
 
virtual bool hasHeightForWidth () const
 
bool hasMouseTracking () const
 
int height () const
 
virtual int heightForWidth (int width) const
 
Qt::InputMethodHints inputMethodHints () const
 
void insertAction (QAction *before, QAction *action)
 
void insertActions (QAction *before, QList< QAction * > actions)
 
bool isActiveWindow () const
 
bool isAncestorOf (const QWidget *child) const
 
bool isEnabled () const
 
bool isEnabledTo (const QWidget *parent) const
 
bool isEnabledToTLW () const
 
bool isFullScreen () const
 
bool isHidden () const
 
bool isMaximized () const
 
bool isMinimized () const
 
bool isModal () const
 
bool isTopLevel () const
 
bool isVisible () const
 
bool isVisibleTo (const QWidget *parent) const
 
bool isWindow () const
 
bool isWindowModified () const
 
QLayoutlayout () const
 
Qt::LayoutDirection layoutDirection () const
 
QLocale locale () const
 
QPoint mapFrom (const QWidget *parent, const QPoint &pos) const
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapFromParent (const QPoint &pos) const
 
QPoint mapTo (const QWidget *parent, const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QPoint mapToParent (const QPoint &pos) const
 
QRegion mask () const
 
int maximumHeight () const
 
QSize maximumSize () const
 
int maximumWidth () const
 
int minimumHeight () const
 
QSize minimumSize () const
 
int minimumWidth () const
 
void move (const QPoint &point)
 
void move (int x, int y)
 
QWidget * nativeParentWidget () const
 
QWidget * nextInFocusChain () const
 
QRect normalGeometry () const
 
void overrideWindowFlags (Qt::WindowFlags flags)
 
QPaintEnginepaintEngine () const override
 
const QPalettepalette () const
 
QWidget * parentWidget () const
 
QPoint pos () const
 
QWidget * previousInFocusChain () const
 
QRect rect () const
 
void releaseKeyboard ()
 
void releaseMouse ()
 
void releaseShortcut (int id)
 
void removeAction (QAction *action)
 
void render (QPaintDevice *target, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren))
 
void render (QPainter *painter, const QPoint &targetOffset=QPoint (), const QRegion &sourceRegion=QRegion (), RenderFlags renderFlags=RenderFlags (DrawWindowBackground|DrawChildren))
 
void repaint (const QRect &rect)
 
void repaint (const QRegion &region)
 
void repaint (int x, int y, int w, int h)
 
void resize (const QSize &size)
 
void resize (int w, int h)
 
bool restoreGeometry (const QByteArray &geometry)
 
QByteArray saveGeometry () const
 
void scroll (int dx, int dy)
 
void scroll (int dx, int dy, const QRect &rect)
 
void setAcceptDrops (bool on)
 
void setAccessibleDescription (const QString &description)
 
void setAccessibleName (const QString &name)
 
void setAttribute (Qt::WidgetAttribute attribute, bool enable=true)
 
void setAutoFillBackground (bool enable)
 
void setBackgroundRole (QPalette::ColorRole role)
 
void setBaseSize (const QSize &size)
 
void setBaseSize (int basew, int baseh)
 
void setContentsMargins (const QMargins &margins)
 
void setContentsMargins (int left, int top, int right, int bottom)
 
void setContextMenuPolicy (Qt::ContextMenuPolicy policy)
 
void setCursor (const QCursor &cursor)
 
void setEditFocus (bool enable)
 
void setFixedHeight (int h)
 
void setFixedSize (const QSize &size)
 
void setFixedSize (int w, int h)
 
void setFixedWidth (int w)
 
void setFocus (Qt::FocusReason reason)
 
void setFocusPolicy (Qt::FocusPolicy policy)
 
void setFocusProxy (QWidget *widget)
 
void setFont (const QFont &font)
 
void setForegroundRole (QPalette::ColorRole role)
 
void setGeometry (const QRect &rect)
 
void setGeometry (int x, int y, int w, int h)
 
void setGraphicsEffect (QGraphicsEffect *effect)
 
void setInputMethodHints (Qt::InputMethodHints hints)
 
void setLayout (QLayout *layout)
 
void setLayoutDirection (Qt::LayoutDirection direction)
 
void setLocale (const QLocale &locale)
 
void setMask (const QBitmap &bitmap)
 
void setMask (const QRegion &region)
 
void setMaximumHeight (int maxh)
 
void setMaximumSize (const QSize &size)
 
void setMaximumSize (int maxw, int maxh)
 
void setMaximumWidth (int maxw)
 
void setMinimumHeight (int minh)
 
void setMinimumSize (const QSize &size)
 
void setMinimumSize (int minw, int minh)
 
void setMinimumWidth (int minw)
 
void setMouseTracking (bool enable)
 
void setPalette (const QPalette &palette)
 
void setParent (QWidget *parent)
 
void setParent (QWidget *parent, Qt::WindowFlags flags)
 
void setShortcutAutoRepeat (int id, bool enable=true)
 
void setShortcutEnabled (int id, bool enable=true)
 
void setSizeIncrement (const QSize &size)
 
void setSizeIncrement (int w, int h)
 
void setSizePolicy (QSizePolicy policy)
 
void setSizePolicy (QSizePolicy::Policy horizontal, QSizePolicy::Policy vertical)
 
void setStatusTip (const QString &data)
 
void setStyle (QStyle *style)
 
void setToolTip (const QString &data)
 
void setToolTipDuration (int msec)
 
void setUpdatesEnabled (bool enable)
 
void setWhatsThis (const QString &str)
 
void setWindowFilePath (const QString &filePath)
 
void setWindowFlags (Qt::WindowFlags flags)
 
void setWindowIcon (const QIcon &icon)
 
void setWindowModality (Qt::WindowModality windowModality)
 
void setWindowOpacity (qreal level)
 
void setWindowRole (const QString &role)
 
void setWindowState (Qt::WindowStates windowState)
 
QSize size () const
 
QSize sizeIncrement () const
 
QSizePolicy sizePolicy () const
 
void stackUnder (QWidget *widget)
 
QString statusTip () const
 
QStylestyle () const
 
QString styleSheet () const
 
bool testAttribute (Qt::WidgetAttribute attribute) const
 
QString toolTip () const
 
int toolTipDuration () const
 
QWidget * topLevelWidget () const
 
bool underMouse () const
 
void ungrabGesture (Qt::GestureType gestureType)
 
void unsetCursor ()
 
void unsetLayoutDirection ()
 
void unsetLocale ()
 
void update (const QRect &rect)
 
void update (const QRegion &region)
 
void update (int x, int y, int w, int h)
 
void updateGeometry ()
 
bool updatesEnabled () const
 
QRegion visibleRegion () const
 
QString whatsThis () const
 
int width () const
 
QWidget * window () const
 
QString windowFilePath () const
 
Qt::WindowFlags windowFlags () const
 
QWindowwindowHandle () const
 
QIcon windowIcon () const
 
Qt::WindowModality windowModality () const
 
qreal windowOpacity () const
 
QString windowRole () const
 
Qt::WindowStates windowState () const
 
QString windowTitle () const
 
Qt::WindowType windowType () const
 
WId winId () const
 
int x () const
 
int y () const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 
- Public Methods inherited from QPaintDevice
virtual ~QPaintDevice ()
 
int colorCount () const
 
int depth () const
 
int devicePixelRatio () const
 
qreal devicePixelRatioF () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 

Protected Methods

void dropEvent (QDropEvent *event) override
 
virtual bool dropMimeData (int row, int column, const QMimeData *data, Qt::DropAction action)
 
bool event (QEvent *event) override
 
QModelIndex indexFromItem (QTableWidgetItem *item) const
 
QTableWidgetItemitemFromIndex (const QModelIndex &index) const
 
QList< QTableWidgetItem * > items (const QMimeData *data) const
 
virtual QMimeDatamimeData (const QList< QTableWidgetItem * > &items) const
 
virtual QStringList mimeTypes () const
 
virtual Qt::DropActions supportedDropActions () const
 
- Protected Methods inherited from QTableView
void currentChanged (const QModelIndex &current, const QModelIndex &previous) override
 
int horizontalOffset () const override
 
bool isIndexHidden (const QModelIndex &index) const override
 
QModelIndex moveCursor (CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override
 
void paintEvent (QPaintEvent *event) override
 
void scrollContentsBy (int dx, int dy) override
 
QModelIndexList selectedIndexes () const override
 
void selectionChanged (const QItemSelection &selected, const QItemSelection &deselected) override
 
void setSelection (const QRect &rect, QItemSelectionModel::SelectionFlags flags) override
 
int sizeHintForColumn (int column) const override
 
int sizeHintForRow (int row) const override
 
void timerEvent (QTimerEvent *event) override
 
void updateGeometries () override
 
int verticalOffset () const override
 
QStyleOptionViewItem viewOptions () const override
 
QSize viewportSizeHint () const override
 
QRegion visualRegionForSelection (const QItemSelection &selection) const override
 
- Protected Methods inherited from QAbstractItemView
QPoint dirtyRegionOffset () const
 
void dragEnterEvent (QDragEnterEvent *event) override
 
void dragLeaveEvent (QDragLeaveEvent *event) override
 
void dragMoveEvent (QDragMoveEvent *event) override
 
DropIndicatorPosition dropIndicatorPosition () const
 
virtual bool edit (const QModelIndex &index, EditTrigger trigger, QEvent *event)
 
bool event (QEvent *event) override
 
void executeDelayedItemsLayout ()
 
void focusInEvent (QFocusEvent *event) override
 
bool focusNextPrevChild (bool next) override
 
void focusOutEvent (QFocusEvent *event) override
 
int horizontalStepsPerItem () const
 
void inputMethodEvent (QInputMethodEvent *event) override
 
void keyPressEvent (QKeyEvent *event) override
 
void mouseDoubleClickEvent (QMouseEvent *event) override
 
void mouseMoveEvent (QMouseEvent *event) override
 
void mousePressEvent (QMouseEvent *event) override
 
void mouseReleaseEvent (QMouseEvent *event) override
 
void resizeEvent (QResizeEvent *event) override
 
void scheduleDelayedItemsLayout ()
 
void scrollDirtyRegion (int dx, int dy)
 
virtual QItemSelectionModel::SelectionFlags selectionCommand (const QModelIndex &index, const QEvent *event=nullptr) const
 
void setDirtyRegion (const QRegion &region)
 
void setHorizontalStepsPerItem (int steps)
 
void setState (State state)
 
void setVerticalStepsPerItem (int steps)
 
virtual void startDrag (Qt::DropActions supportedActions)
 
State state () const
 
void timerEvent (QTimerEvent *event) override
 
int verticalStepsPerItem () const
 
bool viewportEvent (QEvent *event) override
 
- Protected Methods inherited from QAbstractScrollArea
void contextMenuEvent (QContextMenuEvent *event) override
 
void dragEnterEvent (QDragEnterEvent *event) override
 
void dragLeaveEvent (QDragLeaveEvent *event) override
 
void dragMoveEvent (QDragMoveEvent *event) override
 
void dropEvent (QDropEvent *event) override
 
bool event (QEvent *event) override
 
void keyPressEvent (QKeyEvent *event) override
 
void mouseDoubleClickEvent (QMouseEvent *event) override
 
void mouseMoveEvent (QMouseEvent *event) override
 
void mousePressEvent (QMouseEvent *event) override
 
void mouseReleaseEvent (QMouseEvent *event) override
 
void paintEvent (QPaintEvent *event) override
 
void resizeEvent (QResizeEvent *event) override
 
void setViewportMargins (const QMargins &margins)
 
void setViewportMargins (int left, int top, int right, int bottom)
 
QMargins viewportMargins () const
 
void wheelEvent (QWheelEvent *event) override
 
- Protected Methods inherited from QFrame
void changeEvent (QEvent *event) override
 
void drawFrame (QPainter *painter)
 
bool event (QEvent *event) override
 
void initStyleOption (QStyleOptionFrame *option) const
 
void paintEvent (QPaintEvent *event) override
 
- Protected Methods inherited from QWidget
virtual void actionEvent (QActionEvent *event)
 
virtual void closeEvent (QCloseEvent *event)
 
void create (WId window=0, bool initializeWindow=true, bool destroyOldWindow=true)
 
void destroy (bool destroyWindow=true, bool destroySubWindows=true)
 
virtual void enterEvent (QEvent *event)
 
bool event (QEvent *event) override
 
bool focusNextChild ()
 
bool focusPreviousChild ()
 
virtual void hideEvent (QHideEvent *event)
 
void initPainter (QPainter *painter) const override
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void leaveEvent (QEvent *event)
 
int metric (PaintDeviceMetric metric) const override
 
virtual void moveEvent (QMoveEvent *event)
 
virtual bool nativeEvent (const QByteArray &eventType, void *message, long *result)
 
virtual void showEvent (QShowEvent *event)
 
virtual void tabletEvent (QTabletEvent *event)
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Protected Methods inherited from QPaintDevice
 QPaintDevice ()
 

Properties

 columnCount
 
 rowCount
 
- Properties inherited from QTableView
 cornerButtonEnabled
 
 gridStyle
 
 showGrid
 
 sortingEnabled
 
 wordWrap
 
- Properties inherited from QAbstractItemView
 alternatingRowColors
 
 autoScroll
 
 autoScrollMargin
 
 defaultDropAction
 
 dragDropMode
 
 dragDropOverwriteMode
 
 dragEnabled
 
 editTriggers
 
 horizontalScrollMode
 
 iconSize
 
 selectionBehavior
 
 selectionMode
 
 showDropIndicator
 
 tabKeyNavigation
 
 textElideMode
 
 verticalScrollMode
 
- Properties inherited from QAbstractScrollArea
 horizontalScrollBarPolicy
 
 verticalScrollBarPolicy
 
- Properties inherited from QFrame
 frameRect
 
 frameShadow
 
 frameShape
 
 frameWidth
 
 lineWidth
 
 midLineWidth
 
- Properties inherited from QWidget
 acceptDrops
 
 accessibleDescription
 
 accessibleName
 
 autoFillBackground
 
 baseSize
 
 childrenRect
 
 childrenRegion
 
 contextMenuPolicy
 
 cursor
 
 enabled
 
 focus
 
 focusPolicy
 
 font
 
 frameGeometry
 
 frameSize
 
 fullScreen
 
 geometry
 
 height
 
 inputMethodHints
 
 isActiveWindow
 
 layoutDirection
 
 locale
 
 maximized
 
 maximumHeight
 
 maximumSize
 
 maximumWidth
 
 minimized
 
 minimumHeight
 
 minimumSize
 
 minimumSizeHint
 
 minimumWidth
 
 modal
 
 mouseTracking
 
 normalGeometry
 
 palette
 
 pos
 
 rect
 
 size
 
 sizeHint
 
 sizeIncrement
 
 sizePolicy
 
 statusTip
 
 styleSheet
 
 toolTip
 
 updatesEnabled
 
 visible
 
 whatsThis
 
 width
 
 windowFilePath
 
 windowFlags
 
 windowIcon
 
 windowIconText
 
 windowModality
 
 windowModified
 
 windowOpacity
 
 windowTitle
 
 x
 
 y
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Public Typedefs inherited from QAbstractItemView
using EditTriggers = QFlags< EditTrigger >
 
- Public Typedefs inherited from QWidget
using RenderFlags = QFlags< RenderFlag >
 
- Public Types inherited from QAbstractItemView
enum  DragDropMode
 
enum  EditTrigger
 
enum  ScrollHint
 
enum  ScrollMode
 
enum  SelectionBehavior
 
enum  SelectionMode
 
- Public Types inherited from QFrame
enum  Shadow
 
enum  Shape
 
enum  StyleMask
 
- Public Types inherited from QWidget
enum  RenderFlag
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric
 
- Static Public Methods inherited from QWidget
static QWidget * createWindowContainer (QWindow *window, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::EmptyFlag)
 
static QWidget * find (WId id)
 
static QWidget * keyboardGrabber ()
 
static QWidget * mouseGrabber ()
 
static void setTabOrder (QWidget *firstWidget, QWidget *secondWidget)
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Protected Types inherited from QAbstractItemView
enum  CursorAction
 
enum  DropIndicatorPosition
 
enum  State
 
- Protected Slots inherited from QTableView
void columnCountChanged (int oldCount, int newCount)
 
void columnMoved (int column, int oldIndex, int newIndex)
 
void columnResized (int column, int oldWidth, int newWidth)
 
void rowCountChanged (int oldCount, int newCount)
 
void rowMoved (int row, int oldIndex, int newIndex)
 
void rowResized (int row, int oldHeight, int newHeight)
 
- Protected Slots inherited from QAbstractItemView
virtual void closeEditor (QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
 
virtual void commitData (QWidget *editor)
 
virtual void currentChanged (const QModelIndex &current, const QModelIndex &previous)
 
virtual void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles=QVector< int >())
 
virtual void editorDestroyed (QObject *editor)
 
virtual void rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 
virtual void rowsInserted (const QModelIndex &parent, int start, int end)
 
virtual void selectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
 
virtual void updateGeometries ()
 
- Protected Slots inherited from QWidget
void updateMicroFocus ()
 

Detailed Description

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 outside the table (with no parent widget) and inserted into the table with setItem():

QTableWidgetItem *newItem = new QTableWidgetItem(tr("%1").formatArg((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 widget Screenshot of Mac OS X style table widget Screenshot of Fusion style table widget
Windows XP style table widget Mac OS X style table widget Fusion style table widget
See also
QTableWidgetItem, QTableView, Model/View Architecture

Constructor & Destructor Documentation

QTableWidget::QTableWidget ( QWidget parent = nullptr)
explicit

Creates a new table view with the given parent.

QTableWidget::QTableWidget ( int  rows,
int  columns,
QWidget parent = nullptr 
)

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

QTableWidget::~QTableWidget ( )

Destroys this QTableWidget.

Method Documentation

void QTableWidget::cellActivated ( int  row,
int  column 
)
signal

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

void QTableWidget::cellChanged ( int  row,
int  column 
)
signal

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

void QTableWidget::cellClicked ( int  row,
int  column 
)
signal

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

void QTableWidget::cellDoubleClicked ( int  row,
int  column 
)
signal

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.

void QTableWidget::cellEntered ( int  row,
int  column 
)
signal

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.

void QTableWidget::cellPressed ( int  row,
int  column 
)
signal

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

QWidget * QTableWidget::cellWidget ( int  row,
int  column 
) const

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

Note
The table takes ownership of the widget.
See also
setCellWidget()
void QTableWidget::clear ( )
slot

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

void QTableWidget::clearContents ( )
slot

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

void QTableWidget::closePersistentEditor ( QTableWidgetItem item)

Closes the persistent editor for item.

See also
openPersistentEditor()
int QTableWidget::column ( const QTableWidgetItem item) const

Returns the column for the item.

int QTableWidget::columnCount ( ) const

Returns the value of the property.

void QTableWidget::currentCellChanged ( int  currentRow,
int  currentColumn,
int  previousRow,
int  previousColumn 
)
signal

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.

int QTableWidget::currentColumn ( ) const

Returns the column of the current item.

See also
currentRow(), setCurrentCell()
QTableWidgetItem * QTableWidget::currentItem ( ) const

Returns the current item.

See also
setCurrentItem()
void QTableWidget::currentItemChanged ( QTableWidgetItem current,
QTableWidgetItem previous 
)
signal

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.

int QTableWidget::currentRow ( ) const

Returns the row of the current item.

See also
currentColumn(), setCurrentCell()
void QTableWidget::dropEvent ( QDropEvent event)
overrideprotectedvirtual

Reimplemented from QAbstractItemView::dropEvent()

bool QTableWidget::dropMimeData ( int  row,
int  column,
const QMimeData data,
Qt::DropAction  action 
)
protectedvirtual

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()
void QTableWidget::editItem ( QTableWidgetItem item)

Starts editing the item if it is editable.

bool QTableWidget::event ( QEvent event)
overrideprotected

Reimplemented from QAbstractItemView::event()

QList< QTableWidgetItem * > QTableWidget::findItems ( const QString text,
Qt::MatchFlags  flags 
) const

Finds items that matches the text using the given flags.

QTableWidgetItem * QTableWidget::horizontalHeaderItem ( int  column) const

Returns the horizontal header item for column, column, if one has been set, otherwise returns a nullptr.

See also
setHorizontalHeaderItem()
QModelIndex QTableWidget::indexFromItem ( QTableWidgetItem item) const
protected

Returns the QModelIndex associated with the given item.

void QTableWidget::insertColumn ( int  column)
slot

Inserts an empty column into the table at column.

void QTableWidget::insertRow ( int  row)
slot

Inserts an empty row into the table at row.

bool QTableWidget::isItemSelected ( const QTableWidgetItem item) const
deprecated
Deprecated:
Use QTableWidgetItem::isSelected() instead.

Returns true if the item is selected, otherwise returns false.

bool QTableWidget::isSortingEnabled ( ) const

Returns the value of the property.

QTableWidgetItem * QTableWidget::item ( int  row,
int  column 
) const

Returns the item for the given row and column if one has been set, otherwise returns a nullptr.

See also
setItem()
void QTableWidget::itemActivated ( QTableWidgetItem item)
signal

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

QTableWidgetItem * QTableWidget::itemAt ( const QPoint point) const

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

See also
item()
QTableWidgetItem * QTableWidget::itemAt ( int  x,
int  y 
) const
inline

Returns the item at the position equivalent to QPoint(x, y) in the table widget's coordinate system, or returns a nullptr if the specified point is not covered by an item in the table widget.

See also
item()
void QTableWidget::itemChanged ( QTableWidgetItem item)
signal

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

void QTableWidget::itemClicked ( QTableWidgetItem item)
signal

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

void QTableWidget::itemDoubleClicked ( QTableWidgetItem item)
signal

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

void QTableWidget::itemEntered ( QTableWidgetItem item)
signal

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.

QTableWidgetItem * QTableWidget::itemFromIndex ( const QModelIndex index) const
protected

Returns a pointer to the QTableWidgetItem associated with the given index.

void QTableWidget::itemPressed ( QTableWidgetItem item)
signal

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

const QTableWidgetItem * QTableWidget::itemPrototype ( ) const

Returns the item prototype used by the table.

See also
setItemPrototype()
QList< QTableWidgetItem * > QTableWidget::items ( const QMimeData data) const
protected

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.

void QTableWidget::itemSelectionChanged ( )
signal

This signal is emitted whenever the selection changes.

See also
selectedItems(), QTableWidgetItem::isSelected()
QMimeData * QTableWidget::mimeData ( const QList< QTableWidgetItem * > &  items) const
protectedvirtual

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 then a nullptr is returned rather than a serialized empty list.

QStringList QTableWidget::mimeTypes ( ) const
protectedvirtual

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

See also
mimeData()
void QTableWidget::openPersistentEditor ( QTableWidgetItem item)

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

See also
closePersistentEditor()
void QTableWidget::removeCellWidget ( int  row,
int  column 
)
inline

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

void QTableWidget::removeColumn ( int  column)
slot

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

void QTableWidget::removeRow ( int  row)
slot

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

int QTableWidget::row ( const QTableWidgetItem item) const

Returns the row for the item.

int QTableWidget::rowCount ( ) const

Returns the value of the property.

void QTableWidget::scrollToItem ( const QTableWidgetItem item,
QAbstractItemView::ScrollHint  hint = EnsureVisible 
)
slot

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.

QList< QTableWidgetItem * > QTableWidget::selectedItems ( ) const

Returns a list of all selected items. This method returns a list of pointers to the contents of the selected cells. Use the selectedIndexes() method to retrieve the complete selection including empty cells.

See also
selectedIndexes()
QList< QTableWidgetSelectionRange > QTableWidget::selectedRanges ( ) const

Returns a list of all selected ranges.

See also
QTableWidgetSelectionRange
void QTableWidget::setCellWidget ( int  row,
int  column,
QWidget widget 
)

Sets the given widget to be displayed in the cell in the given row and column, passing the ownership of the widget to the table. If cell widget A is replaced with cell widget B, cell widget A will be deleted. For example, in the code shown below the QLineEdit object will be deleted.

See also
cellWidget()
void QTableWidget::setColumnCount ( int  columns)

Sets the value of the property to columns.

void QTableWidget::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()
void QTableWidget::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(), currentColumn()
void QTableWidget::setCurrentItem ( QTableWidgetItem item)

Sets the current item to item. Unless the selection mode is NoSelection, the item is also be selected.

See also
currentItem(), setCurrentCell()
void QTableWidget::setCurrentItem ( QTableWidgetItem item,
QItemSelectionModel::SelectionFlags  command 
)

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

See also
currentItem(), setCurrentCell()
void QTableWidget::setHorizontalHeaderItem ( int  column,
QTableWidgetItem item 
)

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

See also
horizontalHeaderItem()
void QTableWidget::setHorizontalHeaderLabels ( const QStringList labels)

Sets the horizontal header labels using labels.

void QTableWidget::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. 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 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 and setItem() will not move the row.

See also
item(), takeItem()
void QTableWidget::setItemPrototype ( const 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 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()
void QTableWidget::setItemSelected ( const QTableWidgetItem item,
bool  select 
)
deprecated
Deprecated:
Use QTableWidgetItem::setSelected() instead.

Selects or deselects item depending on select.

See also
isItemSelected()
void QTableWidget::setRangeSelected ( const QTableWidgetSelectionRange range,
bool  select 
)

Selects or deselects the range depending on select.

void QTableWidget::setRowCount ( int  rows)

Sets the value of the property to rows.

void QTableWidget::setSortingEnabled ( bool  enable)

If enable is true then sorting is enabled for the table. Sets the property sortingEnabled. This method will call sortByColumn() with the current sort section and order.

See also
isSortingEnabled()
void QTableWidget::setVerticalHeaderItem ( int  row,
QTableWidgetItem item 
)

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

See also
verticalHeaderItem()
void QTableWidget::setVerticalHeaderLabels ( const QStringList labels)

Sets the vertical header labels using labels.

void QTableWidget::sortItems ( int  column,
Qt::SortOrder  order = Qt::AscendingOrder 
)

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

Qt::DropActions QTableWidget::supportedDropActions ( ) const
protectedvirtual

Returns the drop actions supported by this view.

See also
Qt::DropActions
QTableWidgetItem * QTableWidget::takeHorizontalHeaderItem ( int  column)

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

QTableWidgetItem * QTableWidget::takeItem ( int  row,
int  column 
)

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

QTableWidgetItem * QTableWidget::takeVerticalHeaderItem ( int  row)

Removes the vertical header item at the given row without deleting it.

QTableWidgetItem * QTableWidget::verticalHeaderItem ( int  row) const

Returns the vertical header item for the given row.

See also
setVerticalHeaderItem()
int QTableWidget::visualColumn ( int  logicalColumn) const

Returns the visual column of the given logicalColumn.

QRect QTableWidget::visualItemRect ( const QTableWidgetItem item) const

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

int QTableWidget::visualRow ( int  logicalRow) const

Returns the visual row of the given logicalRow.

Property Documentation

QTableWidget::columnCount

This property holds the number of columns in the table.

By default, for a table constructed without row and column counts, this property contains a value of 0.

PropertiesClass Methods
read columnCount
write setColumnCount
QTableWidget::rowCount

This property holds the number of rows in the table.

By default, for a table constructed without row and column counts, this property contains a value of 0.

PropertiesClass Methods
read rowCount
write setRowCount