Qt logo

QHeader Class Reference


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

#include <qheader.h>

Inherits QTableView.

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 char * 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 position c, or -1 if outside.

int QHeader::cellHeight ( int row ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QTableView.

int QHeader::cellPos ( int i ) const

Returns the position in pixels of section i of the 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::cellWidth ( int col ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QTableView.

int QHeader::count () const

Returns the number of sections in the header.

const char* QHeader::label ( int i )

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.

QHeader::Orientation QHeader::orientation() const

Returns Horizontal if the header is horizontal, Vertical if the header is vertical.

void QHeader::paintCell ( QPainter * p, int row, int col ) [virtual protected]

paints a section of the header.

Reimplemented from QTableView.

void QHeader::resizeEvent ( QResizeEvent * ) [virtual protected]

Handles resize events.

Reimplemented from QWidget.

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 )

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 )

Enable clicking in column i if enable is TRUE, disable otherwise. If i is negative, 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 char * s, int size = -1 )

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.

void QHeader::setMovingEnabled ( bool enable )

Enable the user to exchange columns if enable is TRUE, disable otherwise.

See also: setClickEnabled() and setResizeEnabled().

void QHeader::setOffset ( int x ) [slot]

Scrolls the header such that x becomes the leftmost (or uppermost for vertical headers) visible pixel.

void QHeader::setOrientation ( Orientation orientation )

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 )

Enable user resizing of column i if enable is TRUE, disable otherwise. If i is negative, resizing is enabled/disabled for all columns.

See also: setMovingEnabled() and setClickEnabled().

void QHeader::setTracking ( bool enable )

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::setupPainter ( QPainter * p ) [virtual protected]

sets up the painter.

Reimplemented from QTableView.

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.

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-98 Troll Tech, all rights reserved.

It was generated from the following files:


Copyright © 1998 Troll TechTrademarks
Qt version 1.42