This class provides a header, e.g. a vertical header to display row labels, or a horizontal header to display column labels. It is used by TQTable and TQListView for example.
A header is composed of one or more \fIsections\fR, each of which can display a text label and an iconset. A sort indicator (an arrow) can also be displayed using setSortIndicator().
.PP
Sections are 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 retrieve the number of sections in the header.
.PP
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).
A section can be moved with moveSection(). If setMovingEnabled() is TRUE (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. You don't have to worry about this in practice because the TQHeader API works in terms of section numbers, so it doesn't matter where a particular section has been moved to.
If you want the current index position of a section call mapToIndex() giving it the section number. (This is 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() giving it the index number.
.PP
Here's an example to clarify mapToSection() and mapToIndex():
.PP
<center>.nf
.TS
l - l. Index positions 0 1 2 3 Original section ordering Sect 0 Sect 1 Sect 2 Sect 3 Ordering after the user moves a section Sect 0 Sect 2 Sect 3
.TE
.fi
</center>
.PP
<center>.nf
.TS
l - l. \fIk\fR mapToSection(\fIk\fR) mapToIndex(\fIk\fR) 0 0 0 1 2 3 2 3 1 3 1
.TE
.fi
</center>
.PP
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.
TQHeader 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.
Adds a new section with label text \fIs\fR. 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 \fIsize\fR. If \fIsize\fR < 0, an appropriate size for the text \fIs\fR is chosen.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Adds a new section with iconset \fIiconset\fR and label text \fIs\fR. 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 \fIsize\fR, 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.
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
Use sectionAt() instead.
.PP
Returns the index at which the section is displayed, which contains \fIpos\fR in widget coordinates, or -1 if \fIpos\fR is outside the header sections.
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.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns TRUE if section \fIsection\fR 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.
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
Use mapToIndex() instead.
.PP
Translates from logical index \fIl\fR to actual index (index at which the section \fIl\fR is displayed) . Returns -1 if \fIl\fR is outside the legal range.
\fBWarning:\fR If TQTable 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., TQTable does not call moveSection() to move sections but handles move operations internally.
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
Use mapToSection() instead.
.PP
Translates from actual index \fIa\fR (index at which the section is displayed) to logical index of the section. Returns -1 if \fIa\fR is outside the legal range.
\fBWarning:\fR If TQTable 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., TQTable does not call moveSection() to move sections but handles move operations internally.
If \fIenable\fR is TRUE, any clicks on section \fIsection\fR will result in clicked() signals being emitted; otherwise the section will ignore clicks.
.PP
If \fIsection\fR is -1 (the default) then the \fIenable\fR value is set for all existing sections and will be applied to any new sections that are added.
Sets the text of section \fIsection\fR to \fIs\fR. The section's width is set to \fIsize\fR if \fIsize\fR >= 0; otherwise it is left unchanged. Any icon set that has been set for this section remains unchanged.
.PP
If the section does not exist, nothing happens.
.PP
Examples:
.)l chart/setdataform.cpp and table/small-table-demo/main.cpp.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Sets the icon for section \fIsection\fR to \fIiconset\fR and the text to \fIs\fR. The section's width is set to \fIsize\fR if \fIsize\fR >= 0; otherwise it is left unchanged.
If \fIenable\fR is TRUE the user may resize section \fIsection\fR; otherwise the section may not be manually resized.
.PP
If \fIsection\fR is negative (the default) then the \fIenable\fR value is set for all existing sections and will be applied to any new sections that are added. Example:
.PP
.nf
.br
// Allow resizing of all current and future sections
.br
header->setResizeEnabled(TRUE);
.br
// Disable resizing of section 3, (the fourth section added)
.br
header->setResizeEnabled(FALSE, 3);
.br
.fi
.PP
If the user resizes a section, a sizeChange() signal is emitted.
If \fIb\fR is TRUE, section \fIsection\fR 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 \fIsection\fR will be set to be unstretchable and will not resize when the header is resized.
.PP
If \fIsection\fR is -1, and if \fIb\fR 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.
This signal is emitted when the user has changed the size of a \fIsection\fR from \fIoldSize\fR to \fInewSize\fR. This signal is typically connected to a slot that repaints the table or list that contains the header.
Returns TRUE if the sizeChange() signal is emitted continuously; otherwise returns FALSE. See the "tracking" property for details.
.SS "Property Documentation"
.SH "int count"
This property holds the number of sections in the header.
.PP
Get this property's value with count().
.SH "bool moving"
This property holds whether the header sections can be moved.
.PP
If this property is TRUE (the default) the user can move sections. If the user moves a section the indexChange() signal is emitted.
.PP
See also setClickEnabled() and setResizeEnabled().
.PP
Set this property's value with setMovingEnabled() and get this property's value with isMovingEnabled().
.SH "int offset"
This property holds the header's left-most (or top-most) visible pixel.
.PP
Setting this property will scroll the header so that \fIoffset\fR becomes the left-most (or top-most for vertical headers) visible pixel.
.PP
Set this property's value with setOffset() and get this property's value with offset().
.SH "Orientation orientation"
This property holds the header's orientation.
.PP
The orientation is either Vertical or Horizontal (the default).
.PP
Call setOrientation() before adding labels if you don't provide a size parameter otherwise the sizes will be incorrect.
.PP
Set this property's value with setOrientation() and get this property's value with orientation().
.SH "bool stretching"
This property holds whether the header sections always take up the full width (or height) of the header.
.PP
Set this property's value with setStretchEnabled() and get this property's value with isStretchEnabled().
.SH "bool tracking"
This property holds whether the sizeChange() signal is emitted continuously.
.PP
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.
.PP
Tracking defaults to FALSE.
.PP
Set this property's value with setTracking() and get this property's value with tracking().