Q3Header Class | Qt 4.8 (original) (raw)

The Q3Header class provides a header row or column, e.g. for tables and listviews. More...

Member Function Documentation

Constructs a horizontal header called name, with parent parent.

Constructs a horizontal header called name, with n sections and parent parent.

Destroys the header and all its sections.

int Q3Header::addLabel(const QString & s, int size = -1)

Adds a new section with label text s. Returns the index position where the section was added (at the right for horizontal headers, at the bottom for vertical headers). The section's width is set to size. If size < 0, an appropriate size for the text s is chosen.

int Q3Header::addLabel(const QIcon & icon, const QString & s, int size = -1)

This is an overloaded function.

Adds a new section with icon icon and label text s. Returns the index position where the section was added (at the right for horizontal headers, at the bottom for vertical headers). The section's width is set to size, unless size is negative in which case the size is calculated taking account of the size of the text.

Adjusts the size of the sections to fit the size of the header as completely as possible. Only sections for which isStretchEnabled() is true will be resized.

int Q3Header::cellAt(int pos) const

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

Use sectionPos() instead.

Returns the position in pixels of the section that is displayed at the index i. The position is measured from the start of the header.

int Q3Header::cellSize(int i) const

Use sectionSize() instead.

Returns the size in pixels of the section that is displayed at the index i.

See also setCellSize().

[virtual protected] void Q3Header::changeEvent(QEvent * ev)

Reimplemented from QWidget::changeEvent().

[signal] void Q3Header::clicked(int section)

If isClickEnabled() is true, this signal is emitted when the user clicks section section.

See also pressed() and released().

Returns the total width of all the header columns.

QIcon * Q3Header::iconSet(int section) const

Returns the icon set for section section. If the section does not exist, 0 is returned.

[signal] void Q3Header::indexChange(int section, int fromIndex, int toIndex)

This signal is emitted when the user moves section section from index position fromIndex, to index position toIndex.

bool Q3Header::isClickEnabled(int section = -1) const

Returns true if section section is clickable; otherwise returns false.

If section is out of range (negative or larger than count() - 1): returns true if all sections are clickable; otherwise returns false.

See also setClickEnabled().

bool Q3Header::isResizeEnabled(int section = -1) const

Returns true if section section is resizeable; otherwise returns false.

If section is -1 then this function applies to all sections, i.e. returns true if all sections are resizeable; otherwise returns false.

See also setResizeEnabled().

[virtual protected] void Q3Header::keyPressEvent(QKeyEvent * e)

Reimplemented from QWidget::keyPressEvent().

[virtual protected] void Q3Header::keyReleaseEvent(QKeyEvent * e)

Reimplemented from QWidget::keyReleaseEvent().

QString Q3Header::label(int section) const

Returns the text for section section. If the section does not exist, returns an empty string.

See also setLabel().

int Q3Header::mapToActual(int l) const

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 Q3Header::mapToIndex(int section) const

Returns the index position at which section section is displayed.

int Q3Header::mapToLogical(int a) const

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 Q3Header::mapToSection(int index) const

Returns the number of the section that is displayed at index position index.

[virtual protected] void Q3Header::mouseDoubleClickEvent(QMouseEvent * e)

Reimplemented from QWidget::mouseDoubleClickEvent().

[virtual protected] void Q3Header::mouseMoveEvent(QMouseEvent * e)

Reimplemented from QWidget::mouseMoveEvent().

[virtual protected] void Q3Header::mousePressEvent(QMouseEvent * e)

Reimplemented from QWidget::mousePressEvent().

[virtual protected] void Q3Header::mouseReleaseEvent(QMouseEvent * e)

Reimplemented from QWidget::mouseReleaseEvent().

[virtual] void Q3Header::moveCell(int fromIdx, int toIdx)

Use moveSection() instead.

Moves the section that is currently displayed at index fromIdx to index toIdx.

void Q3Header::moveSection(int section, int toIndex)

Moves section section to index position toIndex.

[signal] void Q3Header::moved(int fromIndex, int toIndex)

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.

[virtual protected] void Q3Header::paintEvent(QPaintEvent * e)

Reimplemented from QWidget::paintEvent().

[virtual protected] void Q3Header::paintSection(QPainter * p, int index, const QRect & fr)

Paints the section at position index, inside rectangle fr (which uses widget coordinates) using painter p.

Calls paintSectionLabel().

[virtual protected] void Q3Header::paintSectionLabel(QPainter * p, int index, const QRect & fr)

Paints the label of the section at position index, inside rectangle fr (which uses widget coordinates) using painter p.

Called by paintSection()

[signal] void Q3Header::pressed(int section)

This signal is emitted when the user presses section section down.

See also released().

[signal] void Q3Header::released(int section)

This signal is emitted when section section is released.

See also pressed().

void Q3Header::removeLabel(int section)

Removes section section. If the section does not exist, nothing happens.

[virtual protected] void Q3Header::resizeEvent(QResizeEvent * e)

Reimplemented from QWidget::resizeEvent().

void Q3Header::resizeSection(int section, int s)

Resizes section section to s pixels wide (or high).

[protected] QRect Q3Header::sRect(int index)

Returns the rectangle covered by the section at index index.

int Q3Header::sectionAt(int pos) const

Returns the index of the section which contains the position pos given in pixels from the left (or top).

See also offset().

[signal] void Q3Header::sectionClicked(int index)

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 that sorts the specified column (or row).

[signal] void Q3Header::sectionHandleDoubleClicked(int section)

This signal is emitted when the user doubleclicks on the edge (handle) of section section.

int Q3Header::sectionPos(int section) const

Returns the position (in pixels) at which the section starts.

See also offset().

QRect Q3Header::sectionRect(int section) const

Returns the rectangle covered by section section.

int Q3Header::sectionSize(int section) const

Returns the width (or height) of the section in pixels.

[virtual] void Q3Header::setCellSize(int section, int s)

Use resizeSection() instead.

Sets the size of the section section to s pixels.

Warning: does not repaint or send out signals

See also cellSize().

[virtual] void Q3Header::setClickEnabled(bool enable, int section = -1)

If enable is true, any clicks on section section will result in clicked() signals being emitted; otherwise the section will ignore clicks.

If section is -1 (the default) then the enable value is set for all existing sections and will be applied to any new sections that are added.

See also isClickEnabled(), setMovingEnabled(), and setResizeEnabled().

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

Sets the text of section section to s. The section's width is set to size if size >= 0; otherwise it is left unchanged. Any icon set that has been set for this section remains unchanged.

If the section does not exist, nothing happens.

See also label().

[virtual] void Q3Header::setLabel(int section, const QIcon & icon, const QString & s, int size = -1)

This is an overloaded function.

Sets the icon for section section to icon and the text to s. The section's width is set to size if size >= 0; otherwise it is left unchanged.

If the section does not exist, nothing happens.

[virtual] void Q3Header::setResizeEnabled(bool enable, int section = -1)

If enable is true the user may resize section section; otherwise the section may not be manually resized.

If section is negative (the default) then the enable value is set for all existing sections and will be applied to any new sections that are added. Example:

header->setResizeEnabled(true);

header->setResizeEnabled(false, 3);

If the user resizes a section, a sizeChange() signal is emitted.

See also isResizeEnabled(), setMovingEnabled(), setClickEnabled(), and setTracking().

void Q3Header::setSortIndicator(int section, Qt::SortOrder order)

Sets a sort indicator onto the specified section. The indicator's order is either Ascending or Descending.

Only one section can show a sort indicator at any one time. If you don't want any section to show a sort indicator pass a section number of -1.

See also sortIndicatorSection() and sortIndicatorOrder().

void Q3Header::setSortIndicator(int section, bool ascending = true)

This is an overloaded function.

Sets the sort indicator to ascending. Use the other overload instead.

[virtual protected] void Q3Header::showEvent(QShowEvent * e)

Reimplemented from QWidget::showEvent().

[signal] void Q3Header::sizeChange(int section, int oldSize, int newSize)

This signal is emitted when the user has changed the size of a section from oldSize to newSize. This signal is typically connected to a slot that repaints the table or list that contains the header.

[virtual] QSize Q3Header::sizeHint() const

Reimplemented from QWidget::sizeHint().

Qt::SortOrder Q3Header::sortIndicatorOrder() const

Returns the implied sort order of the Q3Headers sort indicator.

See also setSortIndicator() and sortIndicatorSection().

int Q3Header::sortIndicatorSection() const

Returns the section showing the sort indicator or -1 if there is no sort indicator.

See also setSortIndicator() and sortIndicatorOrder().