QHeader(3qt)

๐Ÿ“ฆ version 3.3.8b, in fedora 43, fedora 44

โœจ NAME โœจ

QHeader โ€” header row or column, like, for tables and listviews ๐Ÿ’… (this is the QHeader(3qt) page, bestie, straight out of the Qt 3 manual, section 3qt ๐ŸŽ€)


๐ŸŒธ SYNOPSIS ๐ŸŒธ

#include <qheader.h>

Inherits QWidget. Yes queen, she's a widget, she's got lineage ๐Ÿ‘‘

๐Ÿฆ‹ Public Members ๐Ÿฆ‹

  • QHeader ( QWidget * parent = 0, const char * name = 0 )
  • QHeader ( int n, QWidget * parent = 0, const char * name = 0 )
  • ~QHeader ()
  • int addLabel ( const QString & s, int size = -1 )
  • int addLabel ( const QIconSet & iconset, const QString & s, int size = -1 )
  • void removeLabel ( int section )
  • virtual void setLabel ( int section, const QString & s, int size = -1 )
  • virtual void setLabel ( int section, const QIconSet & iconset, const QString & s, 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 enable, int section = -1 )
  • virtual void setResizeEnabled ( bool enable, int section = -1 )
  • virtual void setMovingEnabled ( bool )
  • virtual void setStretchEnabled ( bool b, int section )
  • void setStretchEnabled ( bool b )
  • bool isClickEnabled ( int section = -1 ) const
  • bool isResizeEnabled ( int section = -1 ) const
  • bool isMovingEnabled () const
  • bool isStretchEnabled () const
  • bool isStretchEnabled ( int section ) 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
  • int headerWidth () const
  • QRect sectionRect ( int section ) const
  • virtual void setCellSize ( int section, int s ) (obsolete)
  • int cellSize ( int i ) const (obsolete)
  • int cellPos ( int i ) const (obsolete)
  • int cellAt ( int pos ) const (obsolete)
  • int offset () const
  • int mapToSection ( int index ) const
  • int mapToIndex ( int section ) const
  • int mapToLogical ( int a ) const (obsolete)
  • int mapToActual ( int l ) const (obsolete)
  • void moveSection ( int section, int toIndex )
  • virtual void moveCell ( int fromIdx, int toIdx ) (obsolete)
  • void setSortIndicator ( int section, bool ascending = TRUE ) (obsolete)
  • void setSortIndicator ( int section, SortOrder order )
  • int sortIndicatorSection () const
  • SortOrder sortIndicatorOrder () const
  • void adjustHeaderSize ()

๐Ÿ’ซ Public Slots ๐Ÿ’ซ

  • 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 index ) (obsolete)
  • void moved ( int fromIndex, int toIndex ) (obsolete)
  • void sectionHandleDoubleClicked ( int section )

๐ŸŒˆ Properties ๐ŸŒˆ

  • int count โ€” the number of sections in the header (read only)
  • bool moving โ€” whether the header sections can be moved
  • int offset โ€” the header's left-most (or top-most) visible pixel
  • Orientation orientation โ€” the header's orientation
  • bool stretching โ€” whether the header sections always take up the full width (or height) of the header
  • bool tracking โ€” whether the sizeChange() signal is emitted continuously

๐Ÿงš Protected Members ๐Ÿงš

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

๐Ÿ‘‘ DESCRIPTION ๐Ÿ‘‘

The QHeader class provides a header row or column, e.g. for tables and listviews. No cap, that's literally her whole job and she eats every time ๐Ÿ’…

So basically this class gives you a header โ€” like a vertical header to display row labels, or a horizontal header to display column labels. It's used by QTable and QListView, for example. She's the supporting character who is secretly the main character ๐Ÿซถ

A header is composed of one or more sections, and each section can display a text label and an iconset. You can also get a sort indicator (that's an arrow, bestie) displayed using setSortIndicator(). โœจ

Sections get added with addLabel() and removed with removeLabel(). The label and iconset are set in addLabel() and can be changed later with setLabel(). Use count() to grab the number of sections in the header. It's giving very organized, very demure ๐ŸŽ€

The orientation of the header is set with setOrientation(). If setStretchEnabled() is TRUE, the sections will expand to take up the full width (height for vertical headers) of the header. The user can resize the sections manually if setResizeEnabled() is TRUE. Call adjustHeaderSize() to have the sections resize to occupy the full width (or height). Slay, she adapts ๐ŸŒธ

A section can be moved with moveSection(). If setMovingEnabled() is TRUE (and heads up, that's the default), the user may drag a section from one position to another. If a section is moved, the index positions at which sections were added (with addLabel()) may not be the same after the move. But don't stress, you don't have to worry about this in practice, because the QHeader API works in terms of section numbers, so it doesn't matter where a particular section has been moved to. It's fine, she handles it, iykyk ๐Ÿ˜Œ

If you want the current index position of a section, call mapToIndex() and give it the section number. (That's the number returned by the addLabel() call which created the section.) If you want to get the section number of a section at a particular index position, call mapToSection() and give it the index number.

Here's an example to clarify mapToSection() and mapToIndex():

<center>.nf
</center>
<center>.nf
</center>

In the example above, if we wanted to find out which section is at index position 3 we'd call mapToSection(3) and get a section number of 1 since section 1 was moved. Similarly, if we wanted to know which index position section 2 occupied we'd call mapToIndex(2) and get an index of 1. See, math but make it cute ๐Ÿงฎ๐Ÿ’–

QHeader provides the clicked(), pressed() and released() signals. If the user changes the size of a section, the sizeChange() signal is emitted. If you want to have a sizeChange() signal emitted continuously whilst the user is resizing (rather than just after the resizing is finished), use setTracking(). If the user moves a section, the indexChange() signal is emitted. She's chatty, she tells you everything ๐Ÿ“ฃ

[Image Omitted]

[Image Omitted]

See also QListView, QTable, and Advanced Widgets.

๐Ÿ’– MEMBER FUNCTION DOCUMENTATION ๐Ÿ’–

QHeader::QHeader ( QWidget * parent = 0, const char * name = 0 )

Constructs a horizontal header called name, with parent parent. A whole new baby header, born horizontal, iconic ๐Ÿ’…

QHeader::QHeader ( int n, QWidget * parent = 0, const char * name = 0 )

Constructs a horizontal header called name, with n sections and parent parent. She comes pre-loaded with n sections, no assembly required โœจ

QHeader::~QHeader ()

Destroys the header and all its sections. Rest in peace queen, she takes everything down with her ๐Ÿ’€๐Ÿซถ

int QHeader::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. Very "she picks her own outfit" energy ๐Ÿ‘‘

int QHeader::addLabel ( const QIconSet & iconset, const QString & s, int size = -1 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Adds a new section with iconset iconset 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. Same deal, but now with a lil icon glow-up ๐ŸŽ€

void QHeader::adjustHeaderSize ()

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. Not all of them get the glow-up, only the ones who signed up ๐Ÿ’…

int QHeader::cellAt ( int pos ) const

This function is obsolete. It is provided to keep old source working. 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. Girl, she's retired, call the new number ๐Ÿ“ต

int QHeader::cellPos ( int i ) const

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

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

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Use sectionSize() instead.

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

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

If isClickEnabled() is TRUE, this signal is emitted when the user clicks section section. She felt that tap, bestie ๐Ÿ‘†โœจ

See also pressed() and released().

int QHeader::count () const

Returns the number of sections in the header. See the "count" property for details.

int QHeader::headerWidth () const

Returns the total width of all the header columns. All of them, added up, together, as a family ๐Ÿซถ

QIconSet * QHeader::iconSet ( int section ) const

Returns the icon set for section section. If the section does not exist, 0 is returned. No section, no icons, sorry babe ๐Ÿ™ˆ

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

This signal is emitted when the user moves section section from index position fromIndex, to index position toIndex. She moved, she let everyone know ๐Ÿ’…

bool QHeader::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 QHeader::isMovingEnabled () const

Returns TRUE if the header sections can be moved; otherwise returns FALSE. See the "moving" property for details.

bool QHeader::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().

bool QHeader::isStretchEnabled () const

Returns TRUE if the header sections always take up the full width (or height) of the header; otherwise returns FALSE. See the "stretching" property for details.

bool QHeader::isStretchEnabled ( int section ) const

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns TRUE if section section will resize to take up the full width (or height) of the header; otherwise returns FALSE. If at least one section has stretch enabled, the sections will always take up the full width of the header. One overachiever section and the whole team stretches, that's teamwork ๐Ÿงš

See also setStretchEnabled().

QString QHeader::label ( int section ) const

Returns the text for section section. If the section does not exist, a QString::null is returned.

Example: helpsystem/tooltip.cpp.

  • int QHeader::mapToActual ( int l ) const โ€” ๐Ÿ’€ bestie this one is obsolete. It's only still here so ancient source keeps compiling, and the docs literally say we strongly advise against using it in new code. Use mapToIndex() instead, fr fr. What it does: translates from logical index l to actual index (the 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 โ€” gives you the index position that corresponds to the section number you passed in. โœจ
Warning: if QTable is used to move header sections because of user interaction, the mapping this function exposes will not reflect the order of the headers in the table โ€” i.e. QTable does not call moveSection() to move sections, it handles move operations internally. So likeโ€ฆ don't trust it in that case, ok? ๐Ÿ˜ญ

See also mapToSection().

  • int QHeader::mapToLogical ( int a ) const โ€” also obsolete ๐Ÿชฆ, kept around purely to keep old source working, and strongly advised against in new code. Use mapToSection() instead. Translates from actual index a (the index at which the section is displayed) to the 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 number of the section that corresponds to the specified index. ๐ŸŽฏ
Warning: if QTable is used to move header sections as a result of user interaction, the mapping exposed by this function will not reflect the order of the headers in the table; i.e., QTable does not call moveSection() to move sections but handles move operations internally. Same tea as before, different cup. ๐Ÿ’€

See also mapToIndex().

  • void QHeader::moveCell ( int fromIdx, int toIdx ) [virtual] โ€” obsolete, grandfathered in to keep old source compiling, strongly advised against for new code. Use moveSection() instead. Moves the section that is currently displayed at index fromIdx to index toIdx.
  • void QHeader::moveSection ( int section, int toIndex ) โ€” moves section section to index position toIndex. Simple as that, slay. ๐Ÿ’…
  • void QHeader::moved ( int fromIndex, int toIndex ) [signal] โ€” obsolete โœ‹, here to keep old source working, strongly advised against 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 header's left-most (or top-most) visible pixel. See the "offset" property for details. ๐Ÿ‘€
  • Orientation QHeader::orientation () const โ€” returns the header's orientation. See the "orientation" property for details.
  • void QHeader::paintSection ( QPainter * p, int index, const QRect & fr ) [virtual protected] โ€” paints the section at position index, inside rectangle fr (which uses widget coordinates), using painter p. ๐ŸŽจ

Calls paintSectionLabel().

  • void QHeader::paintSectionLabel ( QPainter * p, int index, const QRect & fr ) [virtual protected] โ€” paints the label of the section at position index, inside rectangle fr (which uses widget coordinates), using painter p. The glow-up part of the paint job. โœจ

Called by paintSection()

  • void QHeader::pressed ( int section ) [signal] โ€” emitted when the user presses section section down. ๐Ÿ‘‡

See also released().

  • void QHeader::released ( int section ) [signal] โ€” emitted when section section is released. ๐Ÿ‘†

See also pressed().

  • void QHeader::removeLabel ( int section ) โ€” removes section section. If the section does not exist, nothing happens. No drama, no error, just vibes. ๐Ÿซถ
  • void QHeader::resizeSection ( int section, int s ) โ€” resizes section section to s pixels wide (or high). ๐Ÿ“
  • QRect QHeader::sRect ( int index ) [protected] โ€” returns the rectangle covered by the section at index index.
  • int QHeader::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.

Example: helpsystem/tooltip.cpp.

  • void QHeader::sectionClicked ( int index ) [signal] โ€” obsolete ๐Ÿ˜ญ, provided to keep old source working, strongly advised against 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 that sorts the specified column (or row).

  • void QHeader::sectionHandleDoubleClicked ( int section ) [signal] โ€” emitted when the user doubleclicks on the edge (handle) of section section. Double-tap the handle bestie. โœŒ๏ธ
  • int QHeader::sectionPos ( int section ) const โ€” returns the position (in pixels) at which the section starts.

See also offset.

  • QRect QHeader::sectionRect ( int section ) const โ€” returns the rectangle covered by section section. ๐ŸŸฆ

Example: helpsystem/tooltip.cpp.

  • int QHeader::sectionSize ( int section ) const โ€” returns the width (or height) of the section in pixels.
  • void QHeader::setCellSize ( int section, int s ) [virtual] โ€” obsolete, kept for old source, strongly advised against in new code. Use resizeSection() instead. Sets the size of the section section to s pixels.
Warning: does not repaint or send out signals. ๐Ÿ‘ป It justโ€ฆ does the thing silently. Iconic but also scary.
  • void QHeader::setClickEnabled ( bool enable, int section = -1 ) [virtual] โ€” 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 moving and setResizeEnabled().

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

Examples:

  • void QHeader::setLabel ( int section, const QIconSet & iconset, const QString & s, int size = -1 ) [virtual] โ€” this is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the icon for section section to iconset 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.

  • void QHeader::setMovingEnabled ( bool ) [virtual] โ€” sets whether the header sections can be moved. See the "moving" property for details.
  • void QHeader::setOffset ( int pos ) [virtual slot] โ€” sets the header's left-most (or top-most) visible pixel to pos. See the "offset" property for details.
  • void QHeader::setOrientation ( Orientation ) [virtual] โ€” sets the header's orientation. See the "orientation" property for details.
  • void QHeader::setResizeEnabled ( bool enable, int section = -1 ) [virtual] โ€” 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:

// Allow resizing of all current and future sections
header->setResizeEnabled(TRUE);
// Disable resizing of section 3, (the fourth section added)
header->setResizeEnabled(FALSE, 3);

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

See also moving, setClickEnabled(), and tracking.

  • void QHeader::setSortIndicator ( int section, 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 QHeader::setSortIndicator ( int section, bool ascending = TRUE ) โ€” this is an overloaded member function, provided for convenience. It behaves essentially like the above function.

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

Use the other overload instead. ๐Ÿ‘‘

  • void QHeader::setStretchEnabled ( bool b, int section ) [virtual] โ€” if b is TRUE, section section will be resized when the header is resized, so that the sections take up the full width (or height for vertical headers) of the header; otherwise section section will be set to be unstretchable and will not resize when the header is resized. ๐Ÿง˜โ€โ™€๏ธ

If section is -1, and if b is TRUE, then all sections will be resized equally when the header is resized so that they take up the full width (or height for vertical headers) of the header; otherwise all the sections will be set to be unstretchable and will not resize when the header is resized.

See also adjustHeaderSize().

  • void QHeader::setStretchEnabled ( bool b ) โ€” sets whether the header sections always take up the full width (or height) of the header to b. See the "stretching" property for details.
  • void QHeader::setTracking ( bool enable ) [virtual] โ€” sets whether the sizeChange() signal is emitted continuously to enable. See the "tracking" property for details.
  • void QHeader::sizeChange ( int section, int oldSize, int newSize ) [signal] โ€” 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. ๐Ÿ”„
  • SortOrder QHeader::sortIndicatorOrder () const โ€” returns the implied sort order of the QHeader's sort indicator.

See also setSortIndicator() and sortIndicatorSection().

  • int QHeader::sortIndicatorSection () const โ€” returns the section showing the sort indicator, or -1 if there is no sort indicator. ๐ŸŽ€

See also setSortIndicator() and sortIndicatorOrder().

  • bool QHeader::tracking () const โ€” returns TRUE if the sizeChange() signal is emitted continuously; otherwise returns FALSE. See the "tracking" property for details.

๐Ÿก Property Documentation ๐Ÿก

  • int count โ€” this property holds the number of sections in the header. ๐Ÿ”ข

Get this property's value with count().

  • bool moving โ€” this property holds whether the header sections can be moved. ๐Ÿšš

If this property is TRUE (the default) the user can move sections. If the user moves a section the indexChange() signal is emitted.

See also setClickEnabled() and setResizeEnabled().

Set this property's value with setMovingEnabled() and get this property's value with isMovingEnabled().

  • int offset โ€” this property holds the header's left-most (or top-most) visible pixel. ๐Ÿ‘€

Setting this property will scroll the header so that offset becomes the left-most (or top-most for vertical headers) visible pixel.

Set this property's value with setOffset() and get this property's value with offset().

๐Ÿ’ซ Orientation orientation ๐Ÿ’ซ

okay so this property is literally the header's orientation, bestie ๐ŸŽ€ โ€” it decides which way your lil sections are pointing.

The orientation is either Vertical or Horizontal, and Horizontal is the default, no cap. ๐Ÿ‘‘

โš ๏ธ real talk: call setOrientation() before you add labels if you're not passing a size parameter, otherwise the sizes will be incorrect. like, don't come for me when your widths are cursed, i warned you ๐Ÿ˜ญ

Set this property's value with setOrientation() and get this property's value with orientation(). ๐Ÿซถ


๐ŸŒˆ bool stretching ๐ŸŒˆ

this one is giving stretch to fit energy โœจ โ€” it holds whether the header sections always take up the full width (or height) of the header.

Set this property's value with setStretchEnabled() and get this property's value with isStretchEnabled(). ๐Ÿ’…


๐Ÿ“ bool tracking ๐Ÿ“

okay so this property holds whether the sizeChange() signal is emitted continuously โ€” like, is it yapping the whole time or just at the end ๐Ÿ—ฃ๏ธ

If tracking is on, the sizeChange() signal is emitted continuously while the mouse is moved (i.e. when the header is resized). Otherwise it is only emitted when the mouse button is released at the end of resizing. so: live updates vs. one single glow-up at the finish line ๐Ÿฆ‹

Tracking defaults to FALSE. (yes bestie, all caps, that's how the original says it ๐Ÿ’€)

Set this property's value with setTracking() and get this property's value with tracking(). โญ


๐ŸŒธ SEE ALSO ๐ŸŒธ


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


๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Generated automatically from the source code.

(it wasn't a person, it was the machine, and honestly? icon energy ๐Ÿค–โœจ)


๐Ÿฆ‹ BUGS ๐Ÿฆ‹

If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. ๐Ÿ™ (fr fr, they mean it)

The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.

๐Ÿ’€ not me telling you the man page you're literally reading right now is not officially supported... anyway

If you find errors in 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 (3.3.8). ๐Ÿ“


and that's a wrap on the whole QHeader(3qt) page, bestie ๐Ÿฅน๐Ÿ’– this one shipped as Trolltech AS, dated 2 February 2007, and it's the QHeader(3qt) page โ€” go forth and make your headers slay ๐ŸŒˆ๐Ÿ‘‘๐Ÿ’…

๐Ÿ“ฆ where this page comes from