![]() |
Home · Overviews · Examples |
The QHeaderView class provides a header row or header column for item views. More...
Inherits QAbstractItemView.
The QHeaderView class provides a header row or header column for item views.
A QHeaderView displays the headers used in item views such as the QTableView and QTreeView classes. It takes the place of the QHeader class previously used for the same purpose, but uses the Qt's model/view architecture for consistency with the item view classes.
The QHeaderView class is one of the Model/View Classes and is part of Qt's model/view framework.
The header gets the data for each section from the model using the QAbstractItemModel::headerData() function. You can set the data by using QAbstractItemModel::setHeaderData().
Each header has an orientation and a number of sections, given by the count function. A section refers to a part of the header - either a row or a column, depending on the orientation.
Sections can be moved and resized using moveSection and resizeSection; they can also be hidden and shown with hideSection and showSection.
Each section of a header is described by a section ID, specified by its section(), and can be located at a particular visualIndex in the header. A section can have a sort indicator set with setSortIndicator; this indicates whether the items in the associated item view will be sorted in the order given by the section.
For a horizontal header the section is equivalent to a column in the model, and for a vertical header the section is equivalent to a row in the model.
A header can be fixed in place, or made movable with setMovable. It can be made clickable with setClickable, and has resizing behavior in accordance with setResizeMode.
A header emits sectionMoved if the user moves a section, sectionResized if the user resizes a section, and sectionClicked and sectionHandleDoubleClicked in response to mouse clicks. A header also emits sectionCountChanged and sectionAutoResize.
You can identify a section using the logicalIndex and logicalIndexAt functions, or by its index position, using the visualIndex and visualIndexAt functions. The visual index will change if a section is moved, but the logical index will not change.
QTableWidget and QTableView create default headers. If you want the headers to be visible, you can use setVisible().
Note: Each header renders the data for each section itself, and does not rely on a delegate. As a result, calling a header's setItemDelegate function will have no effect.
See also Model/View Programming, QListView, QTableView, and QTreeView.
Copyright © 2007 Trolltech | Trademarks | Qt Jambi 4.3.2_01 |