Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QHeaderView

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.core.QObject
                      com.trolltech.qt.gui.QWidget
                          com.trolltech.qt.gui.QFrame
                              com.trolltech.qt.gui.QAbstractScrollArea
                                  com.trolltech.qt.gui.QAbstractItemView
                                      com.trolltech.qt.gui.QHeaderView

All Implemented Interfaces:
  QPaintDeviceInterface, QtJambiInterface

    public class QHeaderView

extends QAbstractItemView

The QHeaderView class provides a header row or header column for item views. A QHeaderView displays the headers used in item views such as the `QTableView` and `QTreeView` classes. It takes the place of the `QHeader` class previously used for the same purpose, but uses the Qt's model/view architecture for consistency with the item view classes.

The QHeaderView class is one of the Model/View Classes and is part of Qt's model/view framework.

The header gets the data for each section from the model using the `QAbstractItemModel::headerData()` function. You can set the data by using `QAbstractItemModel::setHeaderData()`.

Each header has an `orientation()` and a number of sections, given by the `count()` function. A section refers to a part of the header - either a row or a column, depending on the orientation.

Sections can be moved and resized using `moveSection()` and `resizeSection()`; they can also be hidden and shown with `hideSection()` and `showSection()`.

Each section of a header is described by a section ID, specified by its section(), and can be located at a particular `visualIndex()` in the header. A section can have a sort indicator set with `setSortIndicator()`; this indicates whether the items in the associated item view will be sorted in the order given by the section.

For a horizontal header the section is equivalent to a column in the model, and for a vertical header the section is equivalent to a row in the model.

## Moving Header Sections

A header can be fixed in place, or made movable with `setMovable()`. It can be made clickable with `setClickable()`, and has resizing behavior in accordance with `setResizeMode()`.

A header emits `sectionMoved()` if the user moves a section, `sectionResized()` if the user resizes a section, and `sectionClicked()` and `sectionHandleDoubleClicked()` in response to mouse clicks. A header also emits `sectionCountChanged()` and `sectionAutoResize()` .

You can identify a section using the `logicalIndex()` and `logicalIndexAt()` functions, or by its index position, using the `visualIndex()` and `visualIndexAt()` functions. The visual index will change if a section is moved, but the logical index will not change.

## Appearance

`QTableWidget` and `QTableView` create default headers. If you want the headers to be visible, you can use setVisible().

Not all `ItemDataRole` s will have an effect on a QHeaderView. If you need to draw other roles, you can subclass QHeaderView and reimplement `paintEvent()`. QHeaderView respects the following item data roles: `TextAlignmentRole` , `DisplayRole` , `FontRole` , `DecorationRole` , `ForegroundRole` , and `BackgroundRole` .

Note: Each header renders the data for each section itself, and does not rely on a delegate. As a result, calling a header's `setItemDelegate()` function will have no effect.

See also:
  Model/View Programming, `QListView`, `QTableView`, and `QTreeView`.

Nested Class Summary
`static class` | `QHeaderView.ResizeMode` The resize mode specifies the behavior of the header sections.

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QAbstractItemView
`QAbstractItemView.CursorAction, QAbstractItemView.DragDropMode, QAbstractItemView.DropIndicatorPosition, QAbstractItemView.EditTrigger, QAbstractItemView.EditTriggers, QAbstractItemView.ScrollHint, QAbstractItemView.ScrollMode, QAbstractItemView.SelectionBehavior, QAbstractItemView.SelectionMode, QAbstractItemView.State`

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QFrame
`QFrame.Shadow, QFrame.Shape, QFrame.StyleMask`

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
`QWidget.RenderFlag, QWidget.RenderFlags`

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary
`QSignalEmitter.Signal0` | `geometriesChanged` This signal is emitted when the header geometries has changed.
`QSignalEmitter.Signal2` | `sectionAutoResize` This signal takes 2 generic argument(s).
`QSignalEmitter.Signal1` | `sectionClicked` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal2` | `sectionCountChanged` This signal takes 2 generic argument(s).
`QSignalEmitter.Signal1` | `sectionDoubleClicked` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `sectionEntered` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `sectionHandleDoubleClicked` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal3` | `sectionMoved` This signal takes 3 generic argument(s).
`QSignalEmitter.Signal1` | `sectionPressed` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal3` | `sectionResized` This signal takes 3 generic argument(s).
`QSignalEmitter.Signal2` | `sortIndicatorChanged` This signal takes 2 generic argument(s).

Fields inherited from class com.trolltech.qt.gui.QAbstractItemView
`activated, clicked, doubleClicked, entered, pressed, viewportEntered`

Fields inherited from class com.trolltech.qt.gui.QWidget
`customContextMenuRequested`

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QHeaderView(Qt.Orientation orientation)` Creates a new generic header with the given `orientation` and `parent`.
`QHeaderView(Qt.Orientation orientation, QWidget parent)` Creates a new generic header with the given `orientation` and `parent`.

Method Summary
`boolean` | `cascadingSectionResizes()` This property holds whether interactive resizing will be cascaded to the following sections once the section being resized by the user has reached its minimum size.
`int` | `count()` Returns the number of sections in the header.
`Qt.Alignment` | `defaultAlignment()` This property holds the default alignment of the text in each header section.
`int` | `defaultSectionSize()` This property holds the default size of the header sections before resizing.
`void` | `headerDataChanged(Qt.Orientation orientation, int logicalFirst, int logicalLast)` Updates the changed header sections with the given `orientation`, from `logicalFirst` to `logicalLast` inclusive.
`int` | `hiddenSectionCount()` Returns the number of sections in the header that has been hidden.
`void` | `hideSection(int logicalIndex)` Hides the section specified by `logicalIndex`.
`boolean` | `highlightSections()` This property holds whether the sections containing selected items are highlighted.
`protected void` | `initStyleOption(QStyleOptionHeader option)` Initialize `option` with the values from this QHeaderView.
`boolean` | `isClickable()` Returns true if the header is clickable; otherwise returns false.
`boolean` | `isMovable()` Returns true if the header can be moved by the user; otherwise returns false.
`boolean` | `isSectionHidden(int logicalIndex)` Returns true if the section specified by `logicalIndex` is explicitly hidden from the user; otherwise returns false.
`boolean` | `isSortIndicatorShown()` This property holds whether the sort indicator is shown.
`int` | `length()` Returns the length along the orientation of the header.
`int` | `logicalIndex(int visualIndex)` Returns the logicalIndex for the section at the given `visualIndex` position, or -1 otherwise.
`int` | `logicalIndexAt(int position)` Returns the section that covers the given `position` in the viewport.
`int` | `logicalIndexAt(int x, int y)` Returns the logical index of the section at the given coordinate.
`int` | `logicalIndexAt(QPoint pos)` Returns the logical index of the section at the position given in `pos`.
`int` | `minimumSectionSize()` This property holds the minimum size of the header sections.
`void` | `moveSection(int from, int to)` Moves the section at visual index `from` to occupy visual index `to`.
`int` | `offset()` Returns the offset of the header.
`Qt.Orientation` | `orientation()` Returns the orientation of the header.
`protected void` | `paintSection(QPainter painter, QRect rect, int logicalIndex)` Paints the section specified by the given `logicalIndex`, using the given `painter` and `rect`.
`QHeaderView.ResizeMode` | `resizeMode(int logicalIndex)` Returns the resize mode that applies to the section specified by the given `logicalIndex`.
`void` | `resizeSection(int logicalIndex, int size)` Resizes the section specified by `logicalIndex` to the `size` measured in pixels.
`protected void` | `resizeSections()` Resizes the sections according to their size hints.
`void` | `resizeSections(QHeaderView.ResizeMode mode)` Resizes the sections according to the given `mode`, ignoring the current resize mode.
`boolean` | `restoreState(QByteArray state)` Restores the `state` of this header view.
`QByteArray` | `saveState()` Saves the current state of this header view.
`int` | `sectionPosition(int logicalIndex)` Returns the section position of the given `logicalIndex`, or -1 if the section is hidden.
`protected void` | `sectionsAboutToBeRemoved(com.trolltech.qt.core.QModelIndex parent, int logicalFirst, int logicalLast)` This slot is called when sections are removed from the `parent`, `logicalFirst` and `logicalLast` signify where the sections are removed from.
`boolean` | `sectionsHidden()` Returns true if sections in the header has been hidden; otherwise returns false;
`protected void` | `sectionsInserted(com.trolltech.qt.core.QModelIndex parent, int logicalFirst, int logicalLast)` This slot is called when sections are inserted into the `parent`, `logicalFirst` and `logicalLast` indexes signify where the new sections are inserted.
`int` | `sectionSize(int logicalIndex)` Returns the width (or height for vertical headers) of the given `logicalIndex`.
`protected QSize` | `sectionSizeFromContents(int logicalIndex)` Returns the size of the contents of the section specified by the give `logicalIndex`.
`int` | `sectionSizeHint(int logicalIndex)` Returns a suitable size hint for the section specified by `logicalIndex`.
`boolean` | `sectionsMoved()` Returns true if sections in the header has been moved; otherwise returns false;
`int` | `sectionViewportPosition(int logicalIndex)` Returns the section viewport position of the given `logicalIndex`.
`void` | `setCascadingSectionResizes(boolean enable)` This property holds whether interactive resizing will be cascaded to the following sections once the section being resized by the user has reached its minimum size.
`void` | `setClickable(boolean clickable)` If `clickable` is true, the header will respond to single clicks.
`void` | `setDefaultAlignment(Qt.Alignment alignment)` This property holds the default alignment of the text in each header section.
`void` | `setDefaultAlignment(Qt.AlignmentFlag[] alignment)`
`void` | `setDefaultSectionSize(int size)` This property holds the default size of the header sections before resizing.
`void` | `setHighlightSections(boolean highlight)` This property holds whether the sections containing selected items are highlighted.
`void` | `setMinimumSectionSize(int size)` This property holds the minimum size of the header sections.
`void` | `setMovable(boolean movable)` If `movable` is true, the header may be moved by the user; otherwise it is fixed in place.
`void` | `setOffset(int offset)` Sets the header's offset to `offset`.
`void` | `setOffsetToLastSection()` Sets the offset to make the last section visible.
`void` | `setOffsetToSectionPosition(int visualIndex)` Sets the offset to the start of the section at the given `visualIndex`.
`void` | `setResizeMode(int logicalIndex, QHeaderView.ResizeMode mode)` Sets the constraints on how the section specified by `logicalIndex` in the header can be resized to those described by the given `mode`.
`void` | `setResizeMode(QHeaderView.ResizeMode mode)` Sets the constraints on how the header can be resized to those described by the given `mode`.
`void` | `setSectionHidden(int logicalIndex, boolean hide)` If `hide` is true the section specified by `logicalIndex` is hidden, otherwise the section is shown.
`void` | `setSortIndicator(int logicalIndex, Qt.SortOrder order)` Sets the sort indicator for the section specified by the given `logicalIndex` in the direction specified by `order`, and removes the sort indicator from any other section that was showing it.
`void` | `setSortIndicatorShown(boolean show)` This property holds whether the sort indicator is shown.
`void` | `setStretchLastSection(boolean stretch)` This property holds whether the last visible section in the header takes up all the available space.
`void` | `showSection(int logicalIndex)` Shows the section specified by `logicalIndex`.
`Qt.SortOrder` | `sortIndicatorOrder()` Returns the order for the sort indicator.
`int` | `sortIndicatorSection()` Returns the logical index of the section that has a sort indicator.
`boolean` | `stretchLastSection()` This property holds whether the last visible section in the header takes up all the available space.
`int` | `stretchSectionCount()` Returns the number of sections that are set to resize mode stretch.
`void` | `swapSections(int first, int second)` Swaps the section at visual index `first` with the section at visual index `second`.
`int` | `visualIndex(int logicalIndex)` Returns the visual index position of the section specified by the given `logicalIndex`, or -1 otherwise.
`int` | `visualIndexAt(int position)` Returns the visual index of the section that covers the given `position` in the viewport.

Methods inherited from class com.trolltech.qt.gui.QAbstractItemView
`alternatingRowColors, autoScrollMargin, clearSelection, closeEditor, closePersistentEditor, commitData, currentChanged, currentIndex, dataChanged, dirtyRegionOffset, dragDropMode, dragDropOverwriteMode, dragEnabled, dropIndicatorPosition, edit, edit, editorDestroyed, editTriggers, executeDelayedItemsLayout, hasAutoScroll, horizontalOffset, horizontalScrollMode, iconSize, indexAt, indexWidget, isIndexHidden, itemDelegate, itemDelegate, itemDelegateForColumn, itemDelegateForRow, keyboardSearch, model, moveCursor, openPersistentEditor, reset, rootIndex, rowsAboutToBeRemoved, rowsInserted, scheduleDelayedItemsLayout, scrollDirtyRegion, scrollTo, scrollTo, scrollToBottom, scrollToTop, selectAll, selectedIndexes, selectionBehavior, selectionChanged, selectionCommand, selectionCommand, selectionMode, selectionModel, setAlternatingRowColors, setAutoScroll, setAutoScrollMargin, setCurrentIndex, setDirtyRegion, setDragDropMode, setDragDropOverwriteMode, setDragEnabled, setDropIndicatorShown, setEditTriggers, setEditTriggers, setHorizontalScrollMode, setIconSize, setIndexWidget, setItemDelegate, setItemDelegateForColumn, setItemDelegateForRow, setModel, setRootIndex, setSelection, setSelectionBehavior, setSelectionMode, setSelectionModel, setState, setTabKeyNavigation, setTextElideMode, setVerticalScrollMode, showDropIndicator, sizeHintForColumn, sizeHintForIndex, sizeHintForRow, startDrag, startDrag, state, tabKeyNavigation, textElideMode, update, updateGeometries, verticalOffset, verticalScrollMode, viewOptions, visualRect, visualRegionForSelection`

Methods inherited from class com.trolltech.qt.gui.QAbstractScrollArea
`addScrollBarWidget, addScrollBarWidget, cornerWidget, horizontalScrollBar, horizontalScrollBarPolicy, maximumViewportSize, scrollBarWidgets, scrollBarWidgets, scrollContentsBy, setCornerWidget, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setupViewport, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportMargins, verticalScrollBar, verticalScrollBarPolicy, viewport, viewportEvent`

Methods inherited from class com.trolltech.qt.gui.QFrame
`frameRect, frameShadow, frameShape, frameStyle, frameWidth, lineWidth, midLineWidth, setFrameRect, setFrameShadow, setFrameShape, setFrameStyle, setLineWidth, setMidLineWidth`

Methods inherited from class com.trolltech.qt.gui.QWidget
`acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, changeEvent, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, cursor, depth, destroy, destroy, destroy, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, effectiveWinId, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isMaximized, isMinimized, isModal, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, languageChange, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nativeParentWidget, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, overrideWindowState, paintEngine, paintEvent, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFilePath, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFilePath, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y`

Methods inherited from class com.trolltech.qt.core.QObject
`childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty`

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Field Detail

### geometriesChanged

    public final QSignalEmitter.Signal0 geometriesChanged

  This signal is emitted when the header geometries has changed.

### sectionAutoResize

    public final QSignalEmitter.Signal2 sectionAutoResize

  This signal takes 2 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: logicalIndex), com.trolltech.qt.gui.QHeaderView$ResizeMode(named: mode)>:

  This signal is emitted when a section is automatically resized. The section's logical index is specified by `logicalIndex`, and the resize mode by `mode`.

See also:
  `setResizeMode()`, and `stretchLastSection()`.

### sectionClicked

    public final QSignalEmitter.Signal1 sectionClicked

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: logicalIndex)>:

  This signal is emitted when a section is clicked. The section's logical index is specified by `logicalIndex`.

  Note that the sectionPressed signal will also be emitted.

See also:
  `setClickable()`, and `sectionPressed()` .

### sectionCountChanged

    public final QSignalEmitter.Signal2 sectionCountChanged

  This signal takes 2 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: oldCount), java.lang.Integer(named: newCount)>:

  This signal is emitted when the number of sections changes; i. . when sections are added or deleted. The original count is specified by `oldCount`, and the new count by `newCount`.

See also:
  `count()`, `length()`, and `headerDataChanged()`.

### sectionDoubleClicked

    public final QSignalEmitter.Signal1 sectionDoubleClicked

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: logicalIndex)>:

  This signal is emitted when a section is double-clicked. The section's logical index is specified by `logicalIndex`.

See also:
  `setClickable()`.

### sectionEntered

    public final QSignalEmitter.Signal1 sectionEntered

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: logicalIndex)>:

  This signal is emitted when the cursor moves over the section and the left mouse button is pressed. The section's logical index is specified by `logicalIndex`.

See also:
  `setClickable()`, and `sectionPressed()` .

### sectionHandleDoubleClicked

    public final QSignalEmitter.Signal1 sectionHandleDoubleClicked

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: logicalIndex)>:

  This signal is emitted when a section is double-clicked. The section's logical index is specified by `logicalIndex`.

See also:
  `setClickable()`.

### sectionMoved

    public final QSignalEmitter.Signal3 sectionMoved

  This signal takes 3 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: logicalIndex), java.lang.Integer(named: oldVisualIndex), java.lang.Integer(named: newVisualIndex)>:

  This signal is emitted when a section is moved. The section's logical index is specified by `logicalIndex`, the old index by `oldVisualIndex`, and the new index position by `newVisualIndex`.

See also:
  `moveSection()`.

### sectionPressed

    public final QSignalEmitter.Signal1 sectionPressed

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: logicalIndex)>:

  This signal is emitted when a section is pressed. The section's logical index is specified by `logicalIndex`.

See also:
  `setClickable()`.

### sectionResized

    public final QSignalEmitter.Signal3 sectionResized

  This signal takes 3 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: logicalIndex), java.lang.Integer(named: oldSize), java.lang.Integer(named: newSize)>:

  This signal is emitted when a section is resized. The section's logical number is specified by `logicalIndex`, the old size by `oldSize`, and the new size by `newSize`.

See also:
  `resizeSection()`.

### sortIndicatorChanged

    public final QSignalEmitter.Signal2 sortIndicatorChanged

  This signal takes 2 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Integer(named: logicalIndex), com.trolltech.qt.core.Qt$SortOrder(named: order)>:

  This signal is emitted when the section containing the sort indicator or the order indicated is changed. The section's logical index is specified by `logicalIndex` and the sort order is specified by `order`.

See also:
  `setSortIndicator()`.

Constructor Detail

### QHeaderView

    public QHeaderView(Qt.Orientation orientation)

  Creates a new generic header with the given `orientation` and `parent`.

### QHeaderView

    public QHeaderView(Qt.Orientation orientation,
                       QWidget parent)

  Creates a new generic header with the given `orientation` and `parent`.

Method Detail

### cascadingSectionResizes

    public final boolean cascadingSectionResizes()

  This property holds whether interactive resizing will be cascaded to the following sections once the section being resized by the user has reached its minimum size. This property only affects sections that have `Interactive` as the resize mode.

  The default value is false.

See also:
  `setResizeMode()`.

### count

    public final int count()

  Returns the number of sections in the header.

See also:
  `sectionCountChanged()` , and `length()`.

### defaultAlignment

    public final Qt.Alignment defaultAlignment()

  This property holds the default alignment of the text in each header section.

### defaultSectionSize

    public final int defaultSectionSize()

  This property holds the default size of the header sections before resizing. This property only affects sections that have `Interactive` or `Fixed` as the resize mode.

See also:
  `setResizeMode()`, and `minimumSectionSize`.

### headerDataChanged

    public final void headerDataChanged(Qt.Orientation orientation,
                                        int logicalFirst,
                                        int logicalLast)

  Updates the changed header sections with the given `orientation`, from `logicalFirst` to `logicalLast` inclusive.

### hiddenSectionCount

    public final int hiddenSectionCount()

  Returns the number of sections in the header that has been hidden.

See also:
  `setSectionHidden()`, and `isSectionHidden()`.

### hideSection

    public final void hideSection(int logicalIndex)

  Hides the section specified by `logicalIndex`.

See also:
  `showSection()`, `isSectionHidden()`, `hiddenSectionCount()`, and `setSectionHidden()`.

### highlightSections

    public final boolean highlightSections()

  This property holds whether the sections containing selected items are highlighted. By default, this property is false.

### isClickable

    public final boolean isClickable()

  Returns true if the header is clickable; otherwise returns false. A clickable header could be set up to allow the user to change the representation of the data in the view related to the header.

See also:
  `setClickable()`.

### isMovable

    public final boolean isMovable()

  Returns true if the header can be moved by the user; otherwise returns false.

See also:
  `setMovable()`.

### isSectionHidden

    public final boolean isSectionHidden(int logicalIndex)

  Returns true if the section specified by `logicalIndex` is explicitly hidden from the user; otherwise returns false.

See also:
  `hideSection()`, `showSection()`, `setSectionHidden()`, and `hiddenSectionCount()`.

### isSortIndicatorShown

    public final boolean isSortIndicatorShown()

  This property holds whether the sort indicator is shown. By default, this property is false.

See also:
  `setClickable()`.

### length

    public final int length()

  Returns the length along the orientation of the header.

See also:
  sizeHint(), `setResizeMode()`, and `offset()`.

### logicalIndex

    public final int logicalIndex(int visualIndex)

  Returns the logicalIndex for the section at the given `visualIndex` position, or -1 otherwise.

See also:
  `visualIndex()`, and `sectionPosition()`.

### logicalIndexAt

    public final int logicalIndexAt(QPoint pos)

  Returns the logical index of the section at the position given in `pos`. If the header is horizontal the x-coordinate will be used to find the logical index; otherwise the y-coordinate will be used.

See also:
  `sectionPosition()`.

### logicalIndexAt

    public final int logicalIndexAt(int position)

  Returns the section that covers the given `position` in the viewport.

See also:
  `visualIndexAt()`, and `isSectionHidden()`.

### logicalIndexAt

    public final int logicalIndexAt(int x,
                                    int y)

  Returns the logical index of the section at the given coordinate. If the header is horizontal `x` will be used, otherwise `y` will be used to find the logical index.

### minimumSectionSize

    public final int minimumSectionSize()

  This property holds the minimum size of the header sections. The minimum section size is the smallest section size allowed. If the minimum section size is set to -1, QHeaderView will use the maximum of the `global strut` or the `font metrics` size.

  This property is honored by all `resize modes` .

See also:
  `setResizeMode()`, and `defaultSectionSize`.

### moveSection

    public final void moveSection(int from,
                                  int to)

  Moves the section at visual index `from` to occupy visual index `to`.

See also:
  `sectionsMoved()`.

### offset

    public final int offset()

  Returns the offset of the header. this is the header's left-most (or top-most for vertical headers) visible pixel.

See also:
  `setOffset()`.

### orientation

    public final Qt.Orientation orientation()

  Returns the orientation of the header.

See also:
  `Qt::Orientation` .

### resizeMode

    public final QHeaderView.ResizeMode resizeMode(int logicalIndex)

  Returns the resize mode that applies to the section specified by the given `logicalIndex`.

See also:
  `setResizeMode()`.

### resizeSection

    public final void resizeSection(int logicalIndex,
                                    int size)

  Resizes the section specified by `logicalIndex` to the `size` measured in pixels.

See also:
  `sectionResized()` , `resizeMode()`, and `sectionSize()`.

### resizeSections

    protected final void resizeSections()

  Resizes the sections according to their size hints. You should not normally need to call this function.

### resizeSections

    public final void resizeSections(QHeaderView.ResizeMode mode)

  Resizes the sections according to the given `mode`, ignoring the current resize mode.

See also:
  `resizeMode()`, and `sectionResized()` .

### restoreState

    public final boolean restoreState(QByteArray state)

  Restores the `state` of this header view. This function returns `true` if the state was restored, otherwise returns false.

See also:
  `saveState()`.

### saveState

    public final QByteArray saveState()

  Saves the current state of this header view.

  To restore the saved state, pass the return value to `restoreState()`.

See also:
  `restoreState()`.

### sectionPosition

    public final int sectionPosition(int logicalIndex)

  Returns the section position of the given `logicalIndex`, or -1 if the section is hidden.

See also:
  `sectionViewportPosition()`.

### sectionSize

    public final int sectionSize(int logicalIndex)

  Returns the width (or height for vertical headers) of the given `logicalIndex`.

See also:
  `length()`, `setResizeMode()`, and `defaultSectionSize()`.

### sectionSizeHint

    public final int sectionSizeHint(int logicalIndex)

  Returns a suitable size hint for the section specified by `logicalIndex`.

See also:
  sizeHint(), `defaultSectionSize()`, `minimumSectionSize()`, and `Qt::SizeHintRole` .

### sectionViewportPosition

    public final int sectionViewportPosition(int logicalIndex)

  Returns the section viewport position of the given `logicalIndex`.

  If the section is hidden, this function returns an undefined value.

See also:
  `sectionPosition()`, and `isSectionHidden()`.

### sectionsAboutToBeRemoved

    protected final void sectionsAboutToBeRemoved(com.trolltech.qt.core.QModelIndex parent,
                                                  int logicalFirst,
                                                  int logicalLast)

  This slot is called when sections are removed from the `parent`, `logicalFirst` and `logicalLast` signify where the sections are removed from. (`logicalFirst` and `logicalLast` will be the same if just one section is removed.)

### sectionsHidden

    public final boolean sectionsHidden()

  Returns true if sections in the header has been hidden; otherwise returns false;

See also.
  `setSectionHidden()`.

### sectionsInserted

    protected final void sectionsInserted(com.trolltech.qt.core.QModelIndex parent,
                                          int logicalFirst,
                                          int logicalLast)

  This slot is called when sections are inserted into the `parent`, `logicalFirst` and `logicalLast` indexes signify where the new sections are inserted.

  `logicalFirst` and `logicalLast` will be the same if just one section is inserted.

### sectionsMoved

    public final boolean sectionsMoved()

  Returns true if sections in the header has been moved; otherwise returns false;

See also.
  `moveSection()`.

### setCascadingSectionResizes

    public final void setCascadingSectionResizes(boolean enable)

  This property holds whether interactive resizing will be cascaded to the following sections once the section being resized by the user has reached its minimum size. This property only affects sections that have `Interactive` as the resize mode.

  The default value is false.

See also:
  `setResizeMode()`.

### setClickable

    public final void setClickable(boolean clickable)

  If `clickable` is true, the header will respond to single clicks.

See also:
  `isClickable()`, `sectionClicked()` , `sectionPressed()` , and `setSortIndicatorShown()`.

### setDefaultAlignment

    public final void setDefaultAlignment(Qt.AlignmentFlag[] alignment)

### setDefaultAlignment

    public final void setDefaultAlignment(Qt.Alignment alignment)

  This property holds the default alignment of the text in each header section.

### setDefaultSectionSize

    public final void setDefaultSectionSize(int size)

  This property holds the default size of the header sections before resizing. This property only affects sections that have `Interactive` or `Fixed` as the resize mode.

See also:
  `setResizeMode()`, and `minimumSectionSize`.

### setHighlightSections

    public final void setHighlightSections(boolean highlight)

  This property holds whether the sections containing selected items are highlighted. By default, this property is false.

### setMinimumSectionSize

    public final void setMinimumSectionSize(int size)

  This property holds the minimum size of the header sections. The minimum section size is the smallest section size allowed. If the minimum section size is set to -1, QHeaderView will use the maximum of the `global strut` or the `font metrics` size.

  This property is honored by all `resize modes` .

See also:
  `setResizeMode()`, and `defaultSectionSize`.

### setMovable

    public final void setMovable(boolean movable)

  If `movable` is true, the header may be moved by the user; otherwise it is fixed in place.

See also:
  `isMovable()`, and `sectionMoved()` .

### setOffset

    public final void setOffset(int offset)

  Sets the header's offset to `offset`.

See also:
  `offset()`, and `length()`.

### setOffsetToLastSection

    public final void setOffsetToLastSection()

  Sets the offset to make the last section visible.

See also:
  `setOffset()`, `sectionPosition()`, and `setOffsetToSectionPosition()`.

### setOffsetToSectionPosition

    public final void setOffsetToSectionPosition(int visualIndex)

  Sets the offset to the start of the section at the given `visualIndex`.

See also:
  `setOffset()`, and `sectionPosition()`.

### setResizeMode

    public final void setResizeMode(QHeaderView.ResizeMode mode)

  Sets the constraints on how the header can be resized to those described by the given `mode`.

See also:
  `resizeMode()`, `length()`, `sectionResized()` , and `sectionAutoResize()` .

### setResizeMode

    public final void setResizeMode(int logicalIndex,
                                    QHeaderView.ResizeMode mode)

  Sets the constraints on how the section specified by `logicalIndex` in the header can be resized to those described by the given `mode`.

### setSectionHidden

    public final void setSectionHidden(int logicalIndex,
                                       boolean hide)

  If `hide` is true the section specified by `logicalIndex` is hidden, otherwise the section is shown.

See also:
  `isSectionHidden()`, and `hiddenSectionCount()`.

### setSortIndicator

    public final void setSortIndicator(int logicalIndex,
                                       Qt.SortOrder order)

  Sets the sort indicator for the section specified by the given `logicalIndex` in the direction specified by `order`, and removes the sort indicator from any other section that was showing it.

See also:
  `sortIndicatorSection()`, and `sortIndicatorOrder()`.

### setSortIndicatorShown

    public final void setSortIndicatorShown(boolean show)

  This property holds whether the sort indicator is shown. By default, this property is false.

See also:
  `setClickable()`.

### setStretchLastSection

    public final void setStretchLastSection(boolean stretch)

  This property holds whether the last visible section in the header takes up all the available space. The default value is false.

  Note: The horizontal headers provided by `QTreeView` are configured with this property set to true, ensuring that the view does not waste any of the space assigned to it for its header. If this value is set to true, this property will override the resize mode set on the last section in the header.

See also:
  `setResizeMode()`.

### showSection

    public final void showSection(int logicalIndex)

  Shows the section specified by `logicalIndex`.

See also:
  `hideSection()`, `isSectionHidden()`, `hiddenSectionCount()`, and `setSectionHidden()`.

### sortIndicatorOrder

    public final Qt.SortOrder sortIndicatorOrder()

  Returns the order for the sort indicator. If no section has a sort indicator the return value of this function is undefined.

See also:
  `setSortIndicator()`, and `sortIndicatorSection()`.

### sortIndicatorSection

    public final int sortIndicatorSection()

  Returns the logical index of the section that has a sort indicator. By default this is section 0.

See also:
  `setSortIndicator()`, `sortIndicatorOrder()`, and `setSortIndicatorShown()`.

### stretchLastSection

    public final boolean stretchLastSection()

  This property holds whether the last visible section in the header takes up all the available space. The default value is false.

  Note: The horizontal headers provided by `QTreeView` are configured with this property set to true, ensuring that the view does not waste any of the space assigned to it for its header. If this value is set to true, this property will override the resize mode set on the last section in the header.

See also:
  `setResizeMode()`.

### stretchSectionCount

    public final int stretchSectionCount()

  Returns the number of sections that are set to resize mode stretch. In views this can be used to see if the headerview needs to resize the sections when the view geometry changes.

See also:
  `stretchLastSection`, and `resizeMode()`.

### swapSections

    public final void swapSections(int first,
                                   int second)

  Swaps the section at visual index `first` with the section at visual index `second`.

See also:
  `moveSection()`.

### visualIndex

    public final int visualIndex(int logicalIndex)

  Returns the visual index position of the section specified by the given `logicalIndex`, or -1 otherwise. Hidden sections still have valid visual indexes.

See also:
  `logicalIndex()`.

### visualIndexAt

    public final int visualIndexAt(int position)

  Returns the visual index of the section that covers the given `position` in the viewport.

See also:
  `logicalIndexAt()`.

### paintSection

    protected void paintSection(QPainter painter,
                                QRect rect,
                                int logicalIndex)

  Paints the section specified by the given `logicalIndex`, using the given `painter` and `rect`.

  You normally would not need to use this function.

### sectionSizeFromContents

    protected QSize sectionSizeFromContents(int logicalIndex)

  Returns the size of the contents of the section specified by the give `logicalIndex`.

See also:
  `defaultSectionSize()`.

### initStyleOption

    protected final void initStyleOption(QStyleOptionHeader option)

  Initialize `option` with the values from this QHeaderView. This method is useful for subclasses when they need a QStyleOptionButton, but don't want to fill in all the information themselves.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD