Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QTableWidget Class

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

 #include <QTableWidget>

Inherits: QTableView.

Public Types

enum DragDropMode { NoDragDrop, DragOnly, DropOnly, DragDrop, InternalMove }
enum EditTrigger { NoEditTriggers, CurrentChanged, DoubleClicked, SelectedClicked, ..., AllEditTriggers }
flags EditTriggers
enum PaintDeviceMetric { PdmWidth, PdmHeight, PdmWidthMM, PdmHeightMM, ..., PdmPhysicalDpiY }
enum ScrollHint { EnsureVisible, PositionAtTop, PositionAtBottom, PositionAtCenter }
enum ScrollMode { ScrollPerItem, ScrollPerPixel }
enum SelectionBehavior { SelectItems, SelectRows, SelectColumns }
enum SelectionMode { SingleSelection, ContiguousSelection, ExtendedSelection, MultiSelection, NoSelection }

Properties

Public Functions

QAbstractItemView(QWidget * parent = 0)
QTableWidget(QWidget * parent = 0)
QTableWidget(int rows, int columns, QWidget * parent = 0)
~QAbstractItemView()
virtual ~QPaintDevice()
~QTableWidget()
bool alternatingRowColors() const
int autoScrollMargin() const
QWidget * cellWidget(int row, int column) const
void closePersistentEditor(QTableWidgetItem * item)
int colorCount() const
int column(const QTableWidgetItem * item) const
int columnCount() const
int currentColumn() const
QModelIndex currentIndex() const
QTableWidgetItem * currentItem() const
int currentRow() const
Qt::DropAction defaultDropAction() const
int depth() const
DragDropMode dragDropMode() const
bool dragDropOverwriteMode() const
bool dragEnabled() const
void editItem(QTableWidgetItem * item)
EditTriggers editTriggers() const
QList<QTableWidgetItem *> findItems(const QString & text, Qt::MatchFlags flags) const
bool hasAutoScroll() const
int height() const
int heightMM() const
QTableWidgetItem * horizontalHeaderItem(int column) const
ScrollMode horizontalScrollMode() const
QSize iconSize() const
virtual QModelIndex indexAt(const QPoint & point) const = 0
QWidget * indexWidget(const QModelIndex & index) const
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const
QTableWidgetItem * item(int row, int column) const
QTableWidgetItem * itemAt(const QPoint & point) const
QTableWidgetItem * itemAt(int ax, int ay) const
QAbstractItemDelegate * itemDelegate() const
QAbstractItemDelegate * itemDelegate(const QModelIndex & index) const
QAbstractItemDelegate * itemDelegateForColumn(int column) const
QAbstractItemDelegate * itemDelegateForRow(int row) const
const QTableWidgetItem * itemPrototype() const
virtual void keyboardSearch(const QString & search)
int logicalDpiX() const
int logicalDpiY() const
QAbstractItemModel * model() const
void openPersistentEditor(QTableWidgetItem * item)
virtual QPaintEngine * paintEngine() const = 0
bool paintingActive() const
int physicalDpiX() const
int physicalDpiY() const
void removeCellWidget(int row, int column)
QModelIndex rootIndex() const
int row(const QTableWidgetItem * item) const
int rowCount() const
virtual void scrollTo(const QModelIndex & index, ScrollHint hint = EnsureVisible) = 0
QList<QTableWidgetItem *> selectedItems()
QList<QTableWidgetSelectionRange> selectedRanges() const
QAbstractItemView::SelectionBehavior selectionBehavior() const
QAbstractItemView::SelectionMode selectionMode() const
QItemSelectionModel * selectionModel() const
void setAlternatingRowColors(bool enable)
void setAutoScroll(bool enable)
void setAutoScrollMargin(int margin)
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 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 setHorizontalHeaderItem(int column, QTableWidgetItem * item)
void setHorizontalHeaderLabels(const QStringList & labels)
void setHorizontalScrollMode(ScrollMode mode)
void setIconSize(const QSize & size)
void setIndexWidget(const QModelIndex & index, QWidget * widget)
void setItem(int row, int column, QTableWidgetItem * item)
void setItemDelegate(QAbstractItemDelegate * delegate)
void setItemDelegateForColumn(int column, QAbstractItemDelegate * delegate)
void setItemDelegateForRow(int row, QAbstractItemDelegate * delegate)
void setItemPrototype(const QTableWidgetItem * item)
virtual void setModel(QAbstractItemModel * model)
void setRangeSelected(const QTableWidgetSelectionRange & range, bool select)
void setRowCount(int rows)
void setSelectionBehavior(QAbstractItemView::SelectionBehavior behavior)
void setSelectionMode(QAbstractItemView::SelectionMode mode)
virtual void setSelectionModel(QItemSelectionModel * selectionModel)
void setTabKeyNavigation(bool enable)
void setTextElideMode(Qt::TextElideMode mode)
void setVerticalHeaderItem(int row, QTableWidgetItem * item)
void setVerticalHeaderLabels(const QStringList & labels)
void setVerticalScrollMode(ScrollMode mode)
bool showDropIndicator() const
virtual int sizeHintForColumn(int column) const
QSize sizeHintForIndex(const QModelIndex & index) const
virtual int sizeHintForRow(int row) const
void sortItems(int column, Qt::SortOrder order = Qt::AscendingOrder)
bool tabKeyNavigation() const
QTableWidgetItem * takeHorizontalHeaderItem(int column)
QTableWidgetItem * takeItem(int row, int column)
QTableWidgetItem * takeVerticalHeaderItem(int row)
Qt::TextElideMode textElideMode() const
QTableWidgetItem * verticalHeaderItem(int row) const
ScrollMode verticalScrollMode() const
int visualColumn(int logicalColumn) const
QRect visualItemRect(const QTableWidgetItem * item) const
virtual QRect visualRect(const QModelIndex & index) const = 0
int visualRow(int logicalRow) const
int width() const
int widthMM() const

Public Slots

void clear()
void clearContents()
void clearSelection()
void edit(const QModelIndex & index)
void insertColumn(int column)
void insertRow(int row)
void removeColumn(int column)
void removeRow(int row)
virtual void reset()
void scrollToBottom()
void scrollToItem(const QTableWidgetItem * item, QAbstractItemView::ScrollHint hint = EnsureVisible)
void scrollToTop()
virtual void selectAll()
void setCurrentIndex(const QModelIndex & index)
virtual void setRootIndex(const QModelIndex & index)
void update(const QModelIndex & index)

Signals

void activated(const QModelIndex & index)
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 clicked(const QModelIndex & index)
void currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn)
void currentItemChanged(QTableWidgetItem * current, QTableWidgetItem * previous)
void doubleClicked(const QModelIndex & index)
void entered(const QModelIndex & index)
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()
void pressed(const QModelIndex & index)
void viewportEntered()

Protected Types

enum CursorAction { MoveUp, MoveDown, MoveLeft, MoveRight, ..., MovePrevious }
enum DropIndicatorPosition { OnItem, AboveItem, BelowItem, OnViewport }
enum State { NoState, DraggingState, DragSelectingState, EditingState, ..., AnimatingState }

Protected Functions

QPaintDevice()
QPoint dirtyRegionOffset() const
virtual void dragEnterEvent(QDragEnterEvent * event)
virtual void dragLeaveEvent(QDragLeaveEvent * event)
virtual void dragMoveEvent(QDragMoveEvent * event)
virtual void dropEvent(QDropEvent * event)
DropIndicatorPosition dropIndicatorPosition() const
virtual bool dropMimeData(int row, int column, const QMimeData * data, Qt::DropAction action)
virtual bool edit(const QModelIndex & index, EditTrigger trigger, QEvent * event)
virtual bool event(QEvent * event)
void executeDelayedItemsLayout()
virtual void focusInEvent(QFocusEvent * event)
virtual bool focusNextPrevChild(bool next)
virtual void focusOutEvent(QFocusEvent * event)
virtual int horizontalOffset() const = 0
QModelIndex indexFromItem(QTableWidgetItem * item) const
virtual void init(QPainter * painter) const
virtual void inputMethodEvent(QInputMethodEvent * event)
virtual bool isIndexHidden(const QModelIndex & index) const = 0
QTableWidgetItem * itemFromIndex(const QModelIndex & index) const
QList<QTableWidgetItem *> items(const QMimeData * data) const
virtual void keyPressEvent(QKeyEvent * event)
virtual int metric(PaintDeviceMetric metric) const
virtual QMimeData * mimeData(const QList<QTableWidgetItem *> items) const
virtual QStringList mimeTypes() const
virtual void mouseDoubleClickEvent(QMouseEvent * event)
virtual void mouseMoveEvent(QMouseEvent * event)
virtual void mousePressEvent(QMouseEvent * event)
virtual void mouseReleaseEvent(QMouseEvent * event)
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) = 0
virtual QPaintDevice * redirected(QPoint * offset) const
virtual void resizeEvent(QResizeEvent * event)
void scheduleDelayedItemsLayout()
void scrollDirtyRegion(int dx, int dy)
virtual QModelIndexList selectedIndexes() const
virtual QItemSelectionModel::SelectionFlags selectionCommand(const QModelIndex & index, const QEvent * event = 0) const
void setDirtyRegion(const QRegion & region)
virtual void setSelection(const QRect & rect, QItemSelectionModel::SelectionFlags flags) = 0
void setState(State state)
virtual QPainter * sharedPainter() const
virtual void startDrag(Qt::DropActions supportedActions)
State state() const
virtual Qt::DropActions supportedDropActions() const
virtual void timerEvent(QTimerEvent * event)
virtual int verticalOffset() const = 0
virtual QStyleOptionViewItem viewOptions() const
virtual bool viewportEvent(QEvent * event)
virtual QRegion visualRegionForSelection(const QItemSelection & selection) const = 0

Reimplemented Protected Functions

virtual void dropEvent(QDropEvent * event)
virtual bool event(QEvent * e)

Protected Slots

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 QSet<int> & roles = QSet<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()
  • 6 protected slots inherited from QTableView
  • 1 protected slot inherited from QWidget

Additional Inherited Members

  • 4 static public members inherited from QWidget
  • 11 static public members inherited from QObject

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 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, and Model/View Programming.

Property Documentation

columnCount : int

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.

Access functions:

int columnCount() const
void setColumnCount(int columns)

rowCount : int

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.

Access functions:

int rowCount() const
void setRowCount(int rows)

Member Function Documentation

QTableWidget::QTableWidget(QWidget * parent = 0)

Creates a new table view with the given parent.

QTableWidget::QTableWidget(int rows, int columns, QWidget * parent = 0)

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

QTableWidget::~QTableWidget()

Destroys this QTableWidget.

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

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

This function was introduced in Qt 4.1.

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.

This function was introduced in Qt 4.1.

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.

This function was introduced in Qt 4.1.

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.

This function was introduced in Qt 4.1.

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.

This function was introduced in Qt 4.1.

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.

This function was introduced in Qt 4.1.

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.

This function was introduced in Qt 4.1.

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.

This function was introduced in Qt 4.2.

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.

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.

This function was introduced in Qt 4.1.

int QTableWidget::currentColumn() const

Returns the column of the current item.

See also currentRow() and 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() and setCurrentCell().

void QTableWidget::dropEvent(QDropEvent * event) [virtual protected]

Reimplemented from QWidget::dropEvent().

bool QTableWidget::dropMimeData(int row, int column, const QMimeData * data, Qt::DropAction action) [virtual protected]

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 * e) [virtual protected]

Reimplemented from QObject::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 0.

See also setHorizontalHeaderItem().

QModelIndex QTableWidget::indexFromItem(QTableWidgetItem * item) const [protected]

Returns the QModelIndex assocated 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.

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

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

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 0 if point is not covered by an item in the table widget.

See also item().

QTableWidgetItem * QTableWidget::itemAt(int ax, int ay) const

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

See also item().

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 assocated 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().

void QTableWidget::itemSelectionChanged() [signal]

This signal is emitted whenever the selection changes.

See also selectedItems() and QTableWidgetItem::isSelected().

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.

QMimeData * QTableWidget::mimeData(const QList<QTableWidgetItem *> items) const [virtual protected]

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.

QStringList QTableWidget::mimeTypes() const [virtual protected]

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)

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

This function was introduced in Qt 4.3.

void QTableWidget::removeColumn(int column) [slot]

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

void QTableWidget::removeRow(int row) [slot]

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

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

Returns the row for the item.

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()

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().

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 snippet below, the QLineEdit object will be deleted.

 setCellWidget(index, new QLineEdit);
 ...
 setCellWidget(index, new QTextEdit);

This function was introduced in Qt 4.1.

See also cellWidget().

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.

This function was introduced in Qt 4.1.

See also setCurrentItem(), currentRow(), and 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.

This function was introduced in Qt 4.4.

See also setCurrentItem(), currentRow(), and 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() and setCurrentCell().

void QTableWidget::setCurrentItem(QTableWidgetItem * item, QItemSelectionModel::SelectionFlags command)

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

This function was introduced in Qt 4.4.

See also currentItem() and setCurrentCell().

void QTableWidget::setHorizontalHeaderItem(int column, QTableWidgetItem * item)

Sets the horizontal header item for column 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.

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

If you want to set several items of a particular row (say, by calling setItem() in a loop), you may want to turn off sorting before doing so, and turn it back on afterwards; this will allow you to use the same row argument for all items in the same row (i.e. setItem() will not move the row).

See also item() and takeItem().

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::setRangeSelected(const QTableWidgetSelectionRange & range, bool select)

Selects or deselects the range depending on select.

void QTableWidget::setVerticalHeaderItem(int row, QTableWidgetItem * item)

Sets the vertical header item for row 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 [virtual protected]

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.

This function was introduced in Qt 4.1.

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 row from the header without deleting it.

This function was introduced in Qt 4.1.

QTableWidgetItem * QTableWidget::verticalHeaderItem(int row) const

Returns the vertical header item for row 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.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web