Eneboo - Documentación para desarrolladores
|
The QHeader class provides a header row or column, e.g. for tables and listviews. Más...
#include <qheader.h>
The QHeader class provides a header row or column, e.g. for tables and listviews.
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 QTable and QListView for example.
A header is composed of one or more sections, each of which can display a text label and an iconset. A sort indicator (an arrow) can also be displayed using setSortIndicator().
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.
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 QHeader 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.
Here's an example to clarify mapToSection() and mapToIndex():
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 Sect 1
k mapToSection(k) mapToIndex(k) 0 0 0 1 2 3 2 3 1 3 1 2
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.
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.
QHeader::QHeader | ( | QWidget * | parent = 0 , |
const char * | name = 0 |
||
) |
Constructs a horizontal header called name, with parent parent.
Constructs a horizontal header called name, with n sections and parent parent.
QHeader::~QHeader | ( | ) |
Destroys the header and all its sections.
QHeader::QHeader | ( | QWidget * | parent = 0 , |
const char * | name = 0 |
||
) |
QHeader::~QHeader | ( | ) |
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.
Reimplementado en QTableHeader.
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. 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.
Reimplementado en QTableHeader.
void QHeader::adjustHeaderSize | ( | ) | [inline] |
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.
void QHeader::adjustHeaderSize | ( | ) | [inline] |
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.
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.
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.
void QHeader::clicked | ( | int | section | ) | [signal] |
int QHeader::count | ( | ) | const |
int QHeader::count | ( | ) | const |
void QHeader::fontChange | ( | const QFont & | oldFont | ) | [protected, virtual] |
This virtual function is called from setFont(). oldFont is the previous font; you can get the new font from font().
Reimplement this function if your widget needs to know when its font changes. You will almost certainly need to update the widget using update().
The default implementation updates the widget including its geometry.
Reimplementado de QWidget.
int QHeader::headerWidth | ( | ) | const |
int QHeader::headerWidth | ( | ) | const |
Returns the total width of all the header columns.
Returns the icon set for section section. If the section does not exist, 0 is returned.
This signal is emitted when the user moves section section from index position fromIndex, to index position toIndex.
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.
bool QHeader::isMovingEnabled | ( | ) | const |
bool QHeader::isMovingEnabled | ( | ) | 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.
bool QHeader::isStretchEnabled | ( | ) | const |
bool QHeader::isStretchEnabled | ( | ) | const |
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. 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.
void QHeader::keyPressEvent | ( | QKeyEvent * | e | ) | [protected, virtual] |
This event handler, for event e, can be reimplemented in a subclass to receive key press events for the widget.
A widget must call setFocusPolicy() to accept focus initially and have focus in order to receive a key press event.
If you reimplement this handler, it is very important that you explicitly ignore the event if you do not understand it, so that the widget's parent can interpret it; otherwise, the event will be implicitly accepted. Although top-level widgets are able to choose whether to accept or ignore unknown events because they have no parent widgets that could otherwise handle them, it is good practice to explicitly ignore events to make widgets as reusable as possible.
The default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored.
Reimplementado de QWidget.
void QHeader::keyReleaseEvent | ( | QKeyEvent * | e | ) | [protected, virtual] |
This event handler, for event e, can be reimplemented in a subclass to receive key release events for the widget.
A widget must accept focus initially and have focus in order to receive a key release event.
If you reimplement this handler, it is very important that you ignore() the release if you do not understand it, so that the widget's parent can interpret it.
The default implementation ignores the event.
Reimplementado de QWidget.
Returns the text for section section. If the section does not exist, a QString::null is returned.
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.
Returns the index position corresponding to the specified section number.
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.
Returns the number of the section that corresponds to the specified index.
void QHeader::mouseDoubleClickEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
Reimplementado en QTableHeader.
void QHeader::mouseDoubleClickEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
This event handler, for event e, can be reimplemented in a subclass to receive mouse double click events for the widget.
The default implementation generates a normal mouse press event.
Note that the widgets gets a mousePressEvent() and a mouseReleaseEvent() before the mouseDoubleClickEvent().
Reimplementado de QWidget.
Reimplementado en QTableHeader.
void QHeader::mouseMoveEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
This event handler, for event e, can be reimplemented in a subclass to receive mouse move events for the widget.
If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.
QMouseEvent::pos() reports the position of the mouse cursor, relative to this widget. For press and release events, the position is usually the same as the position of the last mouse move event, but it might be different if the user's hand shakes. This is a feature of the underlying window system, not Qt.
Reimplementado de QWidget.
Reimplementado en QTableHeader.
void QHeader::mouseMoveEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
Reimplementado en QTableHeader.
void QHeader::mousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
Reimplementado en QTableHeader.
void QHeader::mousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
This event handler, for event e, can be reimplemented in a subclass to receive mouse press events for the widget.
If you create new widgets in the mousePressEvent() the mouseReleaseEvent() may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more.
The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.
Reimplementado de QWidget.
Reimplementado en QTableHeader.
void QHeader::mouseReleaseEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
Reimplementado en QTableHeader.
void QHeader::mouseReleaseEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
This event handler, for event e, can be reimplemented in a subclass to receive mouse release events for the widget.
Reimplementado de QWidget.
Reimplementado en QTableHeader.
Use moveSection() instead.
Moves the section that is currently displayed at index fromIdx to index toIdx.
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.
Moves section section to index position toIndex.
int QHeader::offset | ( | ) | const |
int QHeader::offset | ( | ) | const |
Orientation QHeader::orientation | ( | ) | const |
Orientation QHeader::orientation | ( | ) | const |
void QHeader::paintEvent | ( | QPaintEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
Reimplementado en QTableHeader.
void QHeader::paintEvent | ( | QPaintEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive paint events.
A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint() or update(), or because the widget was obscured and has now been uncovered, or for many other reasons.
Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QCanvas do this, for example.
Qt also tries to speed up painting by merging multiple paint events into one. When update() is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::unite()). repaint() does not permit this optimization, so we suggest using update() when possible.
When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background. There are a couple of exceptions and QPaintEvent::erased() tells you whether the widget has been erased or not.
The background can be set using setBackgroundMode(), setPaletteBackgroundColor() or setBackgroundPixmap(). The documentation for setBackgroundMode() elaborates on the background; we recommend reading it.
Reimplementado de QWidget.
Reimplementado en QTableHeader.
virtual void QHeader::paintSection | ( | QPainter * | p, |
int | index, | ||
const QRect & | fr | ||
) | [protected, virtual] |
Reimplementado en QTableHeader.
Paints the section at position index, inside rectangle fr (which uses widget coordinates) using painter p.
Calls paintSectionLabel().
Reimplementado en QTableHeader.
virtual void QHeader::paintSectionLabel | ( | QPainter * | p, |
int | index, | ||
const QRect & | fr | ||
) | [protected, virtual] |
Paints the label of the section at position index, inside rectangle fr (which uses widget coordinates) using painter p.
Called by paintSection()
void QHeader::pressed | ( | int | section | ) | [signal] |
This signal is emitted when the user presses section section down.
void QHeader::pressed | ( | int | section | ) | [signal] |
void QHeader::released | ( | int | section | ) | [signal] |
This signal is emitted when section section is released.
void QHeader::released | ( | int | section | ) | [signal] |
void QHeader::removeLabel | ( | int | section | ) |
Reimplementado en QTableHeader.
void QHeader::removeLabel | ( | int | section | ) |
Removes section section. If the section does not exist, nothing happens.
Reimplementado en QTableHeader.
void QHeader::resizeEvent | ( | QResizeEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive widget resize events. When resizeEvent() is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::oldSize().
The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler.
Widgets that have been created with the WNoAutoErase
flag will not be erased. Nevertheless, they will receive a paint event for their entire area afterwards. Again, no drawing needs to be done inside this handler.
The default implementation calls updateMask() if the widget has automatic masking enabled.
Reimplementado de QWidget.
Reimplementado en QTableHeader.
void QHeader::resizeEvent | ( | QResizeEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
Reimplementado en QTableHeader.
Resizes section section to s pixels wide (or high).
Reimplementado en QTableHeader.
Returns the index of the section which contains the position pos given in pixels from the left (or top).
Reimplementado en QTableHeader.
void QHeader::sectionClicked | ( | int | index | ) | [signal] |
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::sectionClicked | ( | int | ) | [signal] |
void QHeader::sectionHandleDoubleClicked | ( | int | section | ) | [signal] |
This signal is emitted when the user doubleclicks on the edge (handle) of section section.
void QHeader::sectionHandleDoubleClicked | ( | int | section | ) | [signal] |
Reimplementado en QTableHeader.
Returns the position (in pixels) at which the section starts.
Reimplementado en QTableHeader.
Reimplementado en QTableHeader.
Returns the width (or height) of the section in pixels.
Reimplementado en QTableHeader.
Use resizeSection() instead.
Sets the size of the section section to s pixels.
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.
void QHeader::setLabel | ( | int | section, |
const QIconSet & | iconset, | ||
const QString & | s, | ||
int | size = -1 |
||
) | [virtual] |
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. 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.
Reimplementado en QTableHeader.
Reimplementado en QTableHeader.
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.
Reimplementado en QTableHeader.
virtual void QHeader::setLabel | ( | int | , |
const QIconSet & | , | ||
const QString & | , | ||
int | size = -1 |
||
) | [virtual] |
Reimplementado en QTableHeader.
virtual void QHeader::setMovingEnabled | ( | bool | ) | [virtual] |
void QHeader::setMovingEnabled | ( | bool | enable | ) | [virtual] |
void QHeader::setOffset | ( | int | pos | ) | [virtual, slot] |
virtual void QHeader::setOffset | ( | int | pos | ) | [virtual, slot] |
void QHeader::setOrientation | ( | Orientation | orientation | ) | [virtual] |
virtual void QHeader::setOrientation | ( | Orientation | ) | [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.
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.
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Use the other overload instead.
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.
void QHeader::setStretchEnabled | ( | bool | b | ) | [inline] |
void QHeader::setStretchEnabled | ( | bool | b | ) | [inline] |
virtual void QHeader::setTracking | ( | bool | enable | ) | [virtual] |
void QHeader::setTracking | ( | bool | enable | ) | [inline, virtual] |
void QHeader::showEvent | ( | QShowEvent * | e | ) | [protected, virtual] |
Reimplementado de QWidget.
void QHeader::showEvent | ( | QShowEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive widget show events.
Non-spontaneous show events are sent to widgets immediately before they are shown. The spontaneous show events of top-level widgets are delivered afterwards.
Reimplementado de QWidget.
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.
SortOrder QHeader::sortIndicatorOrder | ( | ) | const |
Qt::SortOrder QHeader::sortIndicatorOrder | ( | ) | const |
Returns the implied sort order of the QHeaders sort indicator.
int QHeader::sortIndicatorSection | ( | ) | const |
Returns the section showing the sort indicator or -1 if there is no sort indicator.
int QHeader::sortIndicatorSection | ( | ) | const |
Returns the rectangle covered by the section at index index.
bool QHeader::tracking | ( | ) | const |
bool QHeader::tracking | ( | ) | const |
QListView [friend] |
QTable [friend] |
Reimplementado en QTableHeader.
QTableHeader [friend] |
int QHeader::count [read] |
the number of sections in the header
bool QHeader::moving [read, write] |
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.
int QHeader::offset [read, write] |
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.
QHeader::Orientation QHeader::orientation [inline, read, write] |
the header's orientation
The orientation is either Vertical
or Horizontal
(the default).
Call setOrientation() before adding labels if you don't provide a size parameter otherwise the sizes will be incorrect.
bool QHeader::stretching [read, write] |
whether the header sections always take up the full width (or height) of the header
bool QHeader::tracking [inline, read, write] |
whether the sizeChange() signal is emitted continuously
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.
Tracking defaults to FALSE.