![]() |
Home · Overviews · Examples |
The QTableView class provides a default model/view implementation of a table view. More...
Inherits QAbstractItemView.
Inherited by QTableWidget.
The QTableView class provides a default model/view implementation of a table view.
A QTableView implements a table view that displays items from a model. This class is used to provide standard tables that were previously provided by the QTable class, but using the more flexible approach provided by Qt's model/view architecture.
The QTableView class is one of the Model/View Classes and is part of Qt's model/view framework.
You can navigate the cells in the table by clicking on a cell with the mouse, or by using the arrow keys. Because QTableView enables tabKeyNavigation by default, you can also hit Tab and Backtab to move from cell to cell.
QTableView implements the interfaces defined by the QAbstractItemView class to allow it to display data provided by models derived from the QAbstractItemModel class.
The table has a vertical header that can be obtained using the verticalHeader function, and a horizontal header that is available through the horizontalHeader function. The height of each row in the table can be found by using rowHeight; similarly, the width of columns can be found using columnWidth. They are both just QWidgets so you can hide either of them using their hide functions.
Rows and columns can be hidden and shown with hideRow, hideColumn, showRow, and showColumn. They can be selected with selectRow and selectColumn. The table will show a grid depending on the showGrid property.
The items shown in a table view, like those in the other item views, are rendered and edited using standard delegates. However, for some tasks it is sometimes useful to be able to insert widgets in a table instead. Widgets are set for particular indexes with the setIndexWidget() function, and later retrieved with indexWidget().
For some specialized forms of tables it is useful to be able to convert between row and column indexes and widget coordinates. The rowAt function provides the y-coordinate within the view of the specified row; the row index can be used to obtain a corresponding y-coordinate with rowViewportPosition. The columnAt and columnViewportPosition functions provide the equivalent conversion operations between x-coordinates and column indexes.
![]() | ![]() | ![]() |
A Windows XP style table view. | A Macintosh style table view. | A Plastique style table view. |
See also QTableWidget, View Classes, QAbstractItemModel, QAbstractItemView, Chart Example, Pixelator Example, and Table Model Example.
Copyright © 2008 Trolltech | Trademarks | Qt Jambi 4.3.5_01 |