QHeader(3qt)

NAME
QHeader - Table header

#include <qheader.h>

Inherits QWidget.

Inherited by QTableHeader.

  Public Members
QHeader ( QWidget * parent=0, const char * name=0 )
QHeader ( int, QWidget * parent=0, const char * name=0 )
~QHeader ()
int addLabel ( const QString &, int size = -1 )
int addLabel ( const QIconSet &, const QString &, int size = -1 )
void removeLabel ( int section )
virtual void setLabel ( int, const QString &, int size = -1 )
virtual void setLabel ( int, const QIconSet &, const QString &, int size = -1 )
QString label ( int section ) const
QIconSet* iconSet ( int section ) const
virtual void setOrientation ( Orientation )
Orientation orientation () const
virtual void setTracking ( bool enable )
bool tracking () const
virtual void setClickEnabled ( bool, int section = -1 )
virtual void setResizeEnabled ( bool, int section = -1 )
virtual void setMovingEnabled ( bool )
bool isClickEnabled ( int section = -1 ) const
bool isResizeEnabled ( int section = -1 ) const
bool isMovingEnabled () const
void resizeSection ( int section, int s )
int sectionSize ( int section ) const
int sectionPos ( int section ) const
int sectionAt ( int pos ) const
int count () const
virtual void setCellSize ( int, int ) (obsolete)
int cellSize ( int ) const (obsolete)
int cellPos ( int ) const (obsolete)
int cellAt ( int ) const (obsolete)
int offset () const
int mapToSection ( int index ) const
int mapToIndex ( int section ) const
int mapToLogical ( int ) const (obsolete)
int mapToActual ( int ) const (obsolete)
void moveSection ( int section, int toIndex )
virtual void moveCell ( int, int ) (obsolete)
void setSortIndicator ( int section, bool increasing = TRUE )

  Public Slots
virtual void setUpdatesEnabled ( bool enable )
virtual void setOffset ( int pos )

  Signals
void clicked ( int section )
void pressed ( int section )
void released ( int section )
void sizeChange ( int section, int oldSize, int newSize )
void indexChange ( int section, int fromIndex, int toIndex )
void sectionClicked ( int ) (obsolete)
void moved ( int, int ) (obsolete)

  Protected Members
QRect sRect ( int index )
void paintSection ( QPainter * p, int index, QRect fr )
void paintSectionLabel ( QPainter * p, int index, const QRect & fr )

  Properties
Type | Name | READ | WRITE | Options
Orientation | orientation | orientation | setOrientation
bool | tracking | tracking | setTracking
int | count | count
int | offset | offset | setOffset
bool | moving | isMovingEnabled | setMovingEnabled

DESCRIPTION
The QHeader class provides a table header.

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.

[Image Omitted]

[Image Omitted]

See also QListView and QTableView.

MEMBER FUNCTION DOCUMENTATION

QHeader::QHeader ( QWidget * parent=0, const char * name=0 )
Constructs a horizontal header.

The parent and name arguments are sent to the QWidget constructor.

QHeader::QHeader ( int n, QWidget * parent=0, const char * name=0 )
Constructs a horizontal header with n sections.

The parent and name arguments are sent to the QWidget constructor.

QHeader::~QHeader ()
Destructs the header.

int QHeader::addLabel ( const QIconSet & iconset, const QString & s, int size = -1 )
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.

int QHeader::addLabel ( const QString & s, int size = -1 )
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.

int QHeader::cellAt ( int pos ) const
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.

int QHeader::cellPos ( int i ) const
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.

int QHeader::cellSize ( int i ) const
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.

void QHeader::clicked ( int section ) [signal]
This signal is emitted when the user clicked onto the section section.

See also pressed() and released().

int QHeader::count () const
Returns the number of sections in the header.

QIconSet * QHeader::iconSet ( int section ) const
Returns the icon set set on section section.

void QHeader::indexChange ( int section, int fromIndex, int toIndex ) [signal]
This signal is emitted if the user moved the section section, which was displayed at the index fromIndex to the new index toIndex.

bool QHeader::isClickEnabled ( int section = -1 ) const
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().

bool QHeader::isMovingEnabled () const
Returns TRUE if the sections of the header can be moved around be the user, otherwise FALSE.

See also setMovingEnabled().

bool QHeader::isResizeEnabled ( int section = -1 ) const
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().

QString QHeader::label ( int section ) const
Returns the text set on section section.

int QHeader::mapToActual ( int l ) const
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().

int QHeader::mapToIndex ( int section ) const
Returns the index at which the section section is currently displayed.

int QHeader::mapToLogical ( int a ) const
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().

int QHeader::mapToSection ( int index ) const
Returns the section which is displayed at the index index.

void QHeader::mouseMoveEvent ( QMouseEvent * e ) [virtual protected]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QHeader::mousePressEvent ( QMouseEvent * e ) [virtual protected]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QHeader::mouseReleaseEvent ( QMouseEvent * e ) [virtual protected]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QHeader::moveCell ( int fromIdx, int toIdx ) [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.

void QHeader::moveSection ( int section, int toIndex )
Moves the section section to be displayed at the index toIndex.

void QHeader::moved ( int fromIndex, int 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.

int QHeader::offset () const
Returns the leftmost (or uppermost for vertical headers) visible pixel.

Orientation QHeader::orientation () const
Returns Horizontal if the header is horizontal, Vertical if the header is vertical.

void QHeader::paintEvent ( QPaintEvent * e ) [virtual protected]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QHeader::paintSection ( QPainter * p, int index, QRect fr ) [protected]
Paints actual section index of the header, inside rectangle fr in widget coordinates.

Calls paintSectionLabel().

void QHeader::paintSectionLabel ( QPainter * p, int index, const QRect & fr ) [protected]
Paints the label of actual section index of the header, inside rectangle fr in widget coordinates.

Called by paintSection().

void QHeader::pressed ( int section ) [signal]
This signal is emitted when the user presses section section down.

See also released().

void QHeader::released ( int section ) [signal]
This signal is emitted when section section is released.

See also pressed().

void QHeader::removeLabel ( int section )
Removes the section section.

void QHeader::resizeSection ( int section, int s )
Resizes the section section to s pixels.

QRect QHeader::sRect ( int index ) [protected]
Returns the rectangle covered by index index.

int QHeader::sectionAt ( int pos ) const
Returns the section which contains the position pos given in pixels.

See also offset().

void QHeader::sectionClicked ( int index ) [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).

int QHeader::sectionPos ( int section ) const
Returns the position (in pixels) at which the section starts.

See also offset().

int QHeader::sectionSize ( int section ) const
Returns the size of the section in pixels.

void QHeader::setCellSize ( int section, int s ) [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.

void QHeader::setClickEnabled ( bool enable, int section = -1 ) [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().

void QHeader::setLabel ( int section, const QIconSet & iconset, const QString & s, int size = -1 ) [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.

void QHeader::setLabel ( int section, const QString & s, int size = -1 ) [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.

void QHeader::setMovingEnabled ( bool enable ) [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().

void QHeader::setOffset ( int x ) [virtual slot]
Scrolls the header such that x becomes the leftmost (or uppermost for vertical headers) visible pixel.

void QHeader::setOrientation ( Orientation orientation ) [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().

void QHeader::setResizeEnabled ( bool enable, int section = -1 ) [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().

void QHeader::setSortIndicator ( int section, bool increasing = TRUE )
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().

void QHeader::setTracking ( bool enable ) [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().

void QHeader::setUpdatesEnabled ( bool enable ) [virtual slot]
reimp.

Reimplemented from QWidget.

void QHeader::showEvent ( QShowEvent * e ) [virtual protected]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QHeader::sizeChange ( int section, int oldSize, int newSize ) [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.

QSize QHeader::sizeHint () const [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

QSizePolicy QHeader::sizePolicy () const [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

bool QHeader::tracking () const
Returns TRUE if tracking is on, FALSE otherwise.

See also setTracking().

SEE ALSO
http://doc.trolltech.com/qheader.html http://www.trolltech.com/faq/tech.html

COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.

BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports make our job much simpler. Thank you.

In case of content or formattting problems with this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qheader.3qt) and the Qt version (2.3.7).