The QHeader class provides a table header. More...
#include <qheader.h>
Inherits QWidget.
Inherited by QTableHeader.
Type | Name | READ | WRITE | Options |
---|---|---|---|---|
Orientation | orientation | orientation | setOrientation | |
bool | tracking | tracking | setTracking | |
int | count | count | ||
int | offset | offset | setOffset | |
bool | moving | isMovingEnabled | setMovingEnabled |
This class provides a table header as known from spreadsheet-like widgets. QHeader can be used vertically or horizontally (see setOrientation()).
With addLabel() you can add sections, and with removeLabel() you can remove them. If you enabled clicking for one or all sections (see setClickEnabled()), the user can reorder the sections and click on them which may be used for sorting (see also setSortIndicator()). This feature is turned on by default.
So, if the user reorders the sections by clicking and moving them with the mouse the index of a section may change. This means, the section you inserted at the first position might be displayed at a different index then. To get the index at which e.g the first section is displayed, use mapToIndex() with 0 as argument for our example.
If you want e.g. to know which section is displayed at e.g. index 3 use mapToSection() with 3 as argument.
So, you can always work with the section numbers as you inserted them without caring about the index at which they are displayed at the moment. Also the API of QHeader works with the section numbers.
See also QListView and QTableView.
Constructs a horizontal header.
The parent and name arguments are sent to the QWidget constructor.
Constructs a horizontal header with n sections.
The parent and name arguments are sent to the QWidget constructor.
Destructs the header.
Adds a new section, with icon set iconset and label text s. Returns the index. If size is non-negative, the section width is set to size, otherwise a size currently sufficient for the label is used.
Adds a new section, with label text s. Returns the index. If size is non-negative, the section width is set to size, otherwise a size currently sufficient for the label text is used.
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.
Use sectionAt() instead!
Returns the index at which the section is displayed, which contains pos in widget coordinates, or -1 if pos is outside the header sections.
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.
Use sectionPos() instead!
Returns the position in pixels of the section which is displayed at the index i. The position is measured from the start of the header.
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.
Use sectionSize() instead!
Returns the size in pixels of the section which is displayed at the index i.
[signal]
This signal is emitted when the user clicked onto the section section.
See also pressed() and released().
Returns the number of sections in the header.
Returns the icon set set on section section.
[signal]
This signal is emitted if the user moved the section section, which was displayed at the index fromIndex to the new index toIndex.
Returns whether the section section is clickable or not. If section is out of range (negative or larger than count() - 1), TRUE is returned if all sections are clickable, else FALSE.
See also setClickEnabled().
Returns TRUE if the sections of the header can be moved around be the user, otherwise FALSE.
See also setMovingEnabled().
Returns whether the section section is resizeable or not. If section is out of range (negative or larger than count() - 1), TRUE is returned if all sections are resizeable, else FALSE.
See also setResizeEnabled().
Returns the text set on section section.
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.
Use mapToIndex() instead!
Translates from logical index l to actual index (index, at which the section l is displayed) . Returns -1 if l is outside the legal range.
See also mapToLogical().
Returns the index at which the section section is currently displayed.
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.
Use mapToSection() instead!
Translates from actual index a (index at which the section is displayed) to logical index of the section. Returns -1 if a is outside the legal range.
See also mapToActual().
Returns the section which is displayed at the index index.
[virtual protected]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
[virtual protected]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
[virtual protected]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
[virtual]
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.
Use moveSection() instead!
Moves the section which is currently displayed at the index fromIndex to the index toIdx.
Moves the section section to be displayed at the index toIndex.
[signal]
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.
Use indexChange() instead!
This signal is emitted when the user has moved the section which is displayed at the index fromIndex to the index toIndex.
Returns the leftmost (or uppermost for vertical headers) visible pixel.
Returns Horizontal
if the header is horizontal, Vertical
if
the header is vertical.
[virtual protected]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
[protected]
Paints actual section index of the header, inside rectangle fr in widget coordinates.
Calls paintSectionLabel().
[protected]
Paints the label of actual section index of the header, inside rectangle fr in widget coordinates.
Called by paintSection().
[signal]
This signal is emitted when the user presses section section down.
See also released().
[signal]
This signal is emitted when section section is released.
See also pressed().
Removes the section section.
Resizes the section section to s pixels.
[protected]
Returns the rectangle covered by index index.
Returns the section which contains the position pos given in pixels.
See also offset().
[signal]
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.
Use clicked() instead!
This signal is emitted when a part of the header is clicked. index is the index at which the section is displayed.
In a list view, this signal would typically be connected to a slot which sorts the specified column (or row).
Returns the position (in pixels) at which the section starts.
See also offset().
Returns the size of the section in pixels.
[virtual]
This function is obsolete. It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code.
Use resizeSection() instead!
Sets the size of the section section to s pixels.
Warning: does not repaint or send out signals.
[virtual]
Enable clicking in section section if enable is TRUE, disable otherwise. If section is negative (as it is by default), clicking is enabled/disabled for all current and new sections.
If enabled, the clicked() signal is emitted when the user clicks.
See also setMovingEnabled() and setResizeEnabled().
[virtual]
Sets the icon on the section section to iconset and the text to s. If the section does not exist, nothing happens. If size is non-negative, the section width is set to size.
Any icon set that has been defined for this section remains unchanged.
[virtual]
Sets the text on section section to s. If the section does not exist, nothing happens. If size is non-negative, the section width is set to size.
Any icon set that has been defined for this section remains unchanged.
[virtual]
Enable the user to exchange sections if enable is TRUE, disable otherwise.
If you enable moving here, the indexChange() signal is emitted if the user moves a section.
See also setClickEnabled() and setResizeEnabled().
[virtual slot]
Scrolls the header such that x becomes the leftmost (or uppermost for vertical headers) visible pixel.
[virtual]
Sets the header orientation. The orientation must be QHeader::Vertical or QHeader::Horizontal.
When adding labels without the size parameter, setOrientation should be called first, otherwise labels will be sized incorrectly.
See also orientation().
[virtual]
Enable user resizing of the section section if enable is TRUE, disable otherwise. If section is negative (as it is by default), resizing is enabled/disabled for all current and new sections.
If the user resizes a section (because this feature enabled it), a sizeChange() signal is emitted.
See also setMovingEnabled() and setClickEnabled().
As often the QHeader is used together with a list widget, QHeader can indicate a sort order. This is done using an arrow at the right edge of a section which points up or down. section specifies in which section this arrow should be drawn, and increasing, if the arrow should point to the bottom (TRUE) or the the top (FALSE). If section is -1, no arrow is drawn.
See also QListView::setShowSortIndicator().
[virtual]
Sets tracking if enable is TRUE, otherwise turns off tracking. If tracking is on, the sizeChange() signal is emitted continuously while the mouse is moved, otherwise it is only emitted when the mouse button is released.
See also tracking().
[virtual slot]
reimp.
Reimplemented from QWidget.
[virtual protected]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
[signal]
This signal is emitted when the user has changed the size of some of a section of the header from oldSize to newSize. This signal is typically connected to a slot that repaints the table.
[virtual]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
[virtual]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
Returns TRUE if tracking is on, FALSE otherwise.
See also setTracking().
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.
Copyright © 2000 Trolltech | Trademarks | Qt version 2.2.1
|