Qt logo

QHeader Class Reference


The QHeader class provides a table header. More...

#include <qheader.h>

Inherits QWidget.

List of all member functions.

Public Members

Public Slots

Signals

Protected Members


Detailed Description

The QHeader class provides a table header.

This is a table heading of the type used in a list view. It gives the user the opportunity to resize and move the columns (or rows for vertical headings).

This class can be used without a table view, if you need to control table-like structures.

See also: QListView, QTableView and Microsoft Style Guide


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 ()

Destroys 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 c ) const

Returns the actual index of the section at widget position c, or -1 if outside.

int QHeader::cellPos ( int i ) const

Returns the position in pixels of section i of the header. The position is measured from the start of the first header. i is the actual index.

int QHeader::cellSize ( int i ) const

Returns the size in pixels of section i of the header. i is the actual index.

int QHeader::count () const

Returns the number of sections in the header.

QIconSet * QHeader::iconSet ( int i ) const

Returns the icon set set on logical section i.

QString QHeader::label ( int i ) const

Returns the text set on logical section i.

int QHeader::mapToActual ( int l ) const

Translates from logical index l to actual index. Returns -1 if l is outside the legal range.

int QHeader::mapToLogical ( int a ) const

Translates from actual index a to logical index. Returns -1 if a is outside the legal range.

void QHeader::moved ( int from, int to ) [signal]

This signal is emitted when the user has moved column from to position to.

int QHeader::offset () const

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]

Paints the header.

Reimplemented from QWidget.

void QHeader::paintSection ( QPainter * p, int id, QRect fr ) [protected]

Paints section id of the header, inside rectangle fr in widget coordinates.

QRect QHeader::sRect ( int i ) [protected]

Returns the rectangle covered by actual section i.

void QHeader::sectionClicked ( int logical ) [signal]

This signal is emitted when a part of the header is clicked. In a list view, this signal would typically be connected to a slot which sorts the specified column.

void QHeader::setCellSize ( int i, int s ) [virtual]

Sets the size of logical cell i to s pixels.

Warning: does not repaint or send out signals at present.

void QHeader::setClickEnabled ( bool enable, int i = -1 ) [virtual]

Enable clicking in logical column i if enable is TRUE, disable otherwise. If i is negative (as it is by default), clicking is enabled/disabled for all columns.

If enabled, the sectionClicked() signal is emitted when the user clicks.

See also: setMovingEnabled() and setResizeEnabled().

void QHeader::setLabel ( int i, const QString & s, int size = -1 ) [virtual]

Sets the text on logical section i 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 columns if enable is TRUE, disable otherwise.

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 i = -1 ) [virtual]

Enable user resizing of logical column i if enable is TRUE, disable otherwise. If i is negative (as it is by default), resizing is enabled/disabled for all columns.

See also: setMovingEnabled() and setClickEnabled().

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::sizeChange ( int section, int oldSize, int newSize ) [signal]

This signal is emitted when the user has changed the size of some of the parts of the header. This signal is typically connected to a slot that repaints the table. section is the logical section resized.

QSize QHeader::sizeHint () const [virtual]

Returns the recommended size of the QHeader.

Reimplemented from QWidget.

QSizePolicy QHeader::sizePolicy () const [virtual]

A horizontal header may stretch horizontally, but is fixed vertically.

Reimplemented from QWidget.

bool QHeader::tracking () const

Returns TRUE if tracking is on, FALSE otherwise.

See also: setTracking().


Search the documentation, FAQ, qt-interest archive and more (uses www.troll.no):


This file is part of the Qt toolkit, copyright © 1995-99 Troll Tech, all rights reserved.


Copyright İ 1999 Troll TechTrademarks
Qt version 2.0.2