![]() |
Home · All Classes · Main Classes · Annotated · Grouped Classes · Functions | ![]() |
The QTableWidget class provides an item-based table view with a default model. More...
#include <QTableWidget>
Part of the QtGui module.
Inherits 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);
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.
See also QTableWidgetItem and Model/View Programming.
This property holds the number of columns in the table.
Access functions:
This property holds the number of rows in the table.
Access functions:
This property holds whether the items in the table can be sorted by clicking on the horizontal header.
Access functions:
Creates a new table view with the given parent.
Creates a new table view with the given rows and columns, and with the given parent.
Destroys this QTableWidget.
Removes all items and selections in the view.
Closes the persistent editor for item.
See also openPersistentEditor().
Returns the column for the item.
Returns the column of the current item.
Returns the current item.
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.
Returns the row of the current item.
Handles the data supplied by a drag and drop operation that ended with the given action in the given row and column.
See also supportedDropActions().
Starts editing the item if it is editable.
Finds items that matches the text using the given flags.
Returns the horizontal header item for column column.
Returns the QModelIndex assocated with the given item.
Inserts an empty column into the table at column.
Inserts an empty row into the table at row.
Returns true if the item is selected, otherwise returns false.
Returns the item for the given row and column.
See also setItem().
This signal is emitted when the specified item has been activated
Returns a pointer to the item at the coordinates p.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
Returns the item at the position (ax, ay) in the table's coordinate system.
This signal is emitted whenever the data of item has changed.
This signal is emitted whenever an item in the table is clicked. The item specified is the item that was clicked.
This signal is emitted whenever an item in the table is double clicked. The item specified is the item that was double clicked.
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.
Returns a pointer to the QTableWidgetItem assocated with the given index.
This signal is emitted whenever an item in the table is pressed. The item specified is the item that was pressed.
Returns the item prototype used by the table.
Copies of the item prototype are returned by the createItem() function.
See also setItemPrototype().
This signal is emitted whenever the selection changes.
See also selectedItems() and isItemSelected().
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.
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.
Returns a list of MIME types that can be used to describe a list of tablewidget items.
See also mimeData().
Opens an editor for the give item. The editor remains open after editing.
See also closePersistentEditor().
Removes the column column and all its items from the table.
Removes the row row and all its items from the table.
Returns the row for the item.
Scrolls the view if necessary to ensure that the item is visible. The hint parameter specifies more precisely where the item should be located after the operation.
Returns a list of all selected items.
Returns a list of all selected ranges.
See also QTableWidgetSelectionRange.
Sets the current item to item.
Sets the horizontal header item for column column to item.
Sets the horizontal header labels using labels.
Sets the item for the given row and column to item.
See also item().
Sets the item prototype for the table to the specified item.
See also itemPrototype().
Selects or deselects item depending on select.
Selects or deselects the range depending on select.
Sets the vertical header item for row row to item.
Sets the vertical header labels using labels.
Sorts all the rows in the table widget based on column and order.
Returns the drop actions supported by this view.
See also Qt::DropActions.
Removes the item at row and column from the table without deleting it.
Returns the vertical header item for row row.
Returns the visual column of the given logicalColumn.
Returns the rectangle on the viewport occupied by the item at item.
Returns the visual row of the given logicalRow.
Copyright © 2005 Trolltech | Trademarks | Qt 4.0.0-rc1 |