Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QHeaderView Class Reference

The QHeaderView class provides a header row or header column for item views. More...

#include <qheaderview.h>

+ Inheritance diagram for QHeaderView:
+ Collaboration diagram for QHeaderView:

Public Types

enum  ResizeMode {
  Interactive , Stretch , Fixed , ResizeToContents ,
  Custom = Fixed
}
 The resize mode specifies the behavior of the header sections. More...
 
- Public Types inherited from QAbstractItemView
enum  SelectionMode {
  NoSelection , SingleSelection , MultiSelection , ExtendedSelection ,
  ContiguousSelection
}
 This enum indicates how the view responds to user selections: More...
 
enum  SelectionBehavior { SelectItems , SelectRows , SelectColumns }
 \value SelectItems Selecting single items. More...
 
enum  ScrollHint { EnsureVisible , PositionAtTop , PositionAtBottom , PositionAtCenter }
 \value EnsureVisible Scroll to ensure that the item is visible. More...
 
enum  EditTrigger {
  NoEditTriggers = 0 , CurrentChanged = 1 , DoubleClicked = 2 , SelectedClicked = 4 ,
  EditKeyPressed = 8 , AnyKeyPressed = 16 , AllEditTriggers = 31
}
 This enum describes actions which will initiate item editing. More...
 
enum  ScrollMode { ScrollPerItem , ScrollPerPixel }
 

Public Slots

void setOffset (int offset)
 Sets the header's offset to offset.
 
void setOffsetToSectionPosition (int visualIndex)
 
void setOffsetToLastSection ()
 
void headerDataChanged (Qt::Orientation orientation, int logicalFirst, int logicalLast)
 Updates the changed header sections with the given orientation, from logicalFirst to logicalLast inclusive.
 
- Public Slots inherited from QAbstractItemView
virtual void setRootIndex (const QModelIndex &index)
 Sets the root item to the item at the given index.
 
virtual void selectAll ()
 Selects all items in the view.
 
void edit (const QModelIndex &index)
 Starts editing the item corresponding to the given index if it is editable.
 
void clearSelection ()
 Deselects all selected items.
 
void setCurrentIndex (const QModelIndex &index)
 Sets the current item to be the item at index.
 
void scrollToTop ()
 
void scrollToBottom ()
 
void update (const QModelIndex &index)
 

Signals

void sectionMoved (int logicalIndex, int oldVisualIndex, int newVisualIndex)
 This signal is emitted when a section is moved.
 
void sectionResized (int logicalIndex, int oldSize, int newSize)
 This signal is emitted when a section is resized.
 
void sectionPressed (int logicalIndex)
 This signal is emitted when a section is pressed.
 
void sectionClicked (int logicalIndex)
 This signal is emitted when a section is clicked.
 
void sectionEntered (int logicalIndex)
 
void sectionDoubleClicked (int logicalIndex)
 This signal is emitted when a section is double-clicked.
 
void sectionCountChanged (int oldCount, int newCount)
 This signal is emitted when the number of sections changes, i.e., when sections are added or deleted.
 
void sectionHandleDoubleClicked (int logicalIndex)
 This signal is emitted when a section is double-clicked.
 
void geometriesChanged ()
 
void sortIndicatorChanged (int logicalIndex, Qt::SortOrder order)
 
void sortIndicatorClearableChanged (bool clearable)
 
- Signals inherited from QAbstractItemView
void pressed (const QModelIndex &index)
 This signal is emitted when a mouse button is pressed.
 
void clicked (const QModelIndex &index)
 This signal is emitted when a mouse button is left-clicked.
 
void doubleClicked (const QModelIndex &index)
 This signal is emitted when a mouse button is double-clicked.
 
void activated (const QModelIndex &index)
 This signal is emitted when the item specified by index is activated by the user.
 
void entered (const QModelIndex &index)
 This signal is emitted when the mouse cursor enters the item specified by index.
 
void viewportEntered ()
 This signal is emitted when the mouse cursor enters the viewport.
 
void iconSizeChanged (const QSize &size)
 

Public Member Functions

 QHeaderView (Qt::Orientation orientation, QWidget *parent=nullptr)
 Creates a new generic header with the given orientation and parent.
 
virtual ~QHeaderView ()
 Destroys the header.
 
void setModel (QAbstractItemModel *model) override
 \reimp
 
Qt::Orientation orientation () const
 Returns the orientation of the header.
 
int offset () const
 Returns the offset of the header: this is the header's left-most (or top-most for vertical headers) visible pixel.
 
int length () const
 Returns the length along the orientation of the header.
 
QSize sizeHint () const override
 Returns a suitable size hint for this header.
 
void setVisible (bool v) override
 \reimp
 
int sectionSizeHint (int logicalIndex) const
 Returns a suitable size hint for the section specified by logicalIndex.
 
int visualIndexAt (int position) const
 Returns the visual index of the section that covers the given position in the viewport.
 
int logicalIndexAt (int position) const
 Returns the section that covers the given position in the viewport.
 
int logicalIndexAt (int x, int y) const
 Returns the logical index of the section at the given coordinate.
 
int logicalIndexAt (const QPoint &pos) const
 Returns the logical index of the section at the position given in pos.
 
int sectionSize (int logicalIndex) const
 Returns the width (or height for vertical headers) of the given logicalIndex.
 
int sectionPosition (int logicalIndex) const
 Returns the section position of the given logicalIndex, or -1 if the section is hidden.
 
int sectionViewportPosition (int logicalIndex) const
 Returns the section viewport position of the given logicalIndex.
 
void moveSection (int from, int to)
 Moves the section at visual index from to occupy visual index to.
 
void swapSections (int first, int second)
 
void resizeSection (int logicalIndex, int size)
 Resizes the section specified by logicalIndex to size measured in pixels.
 
void resizeSections (QHeaderView::ResizeMode mode)
 Resizes the sections according to the given mode, ignoring the current resize mode.
 
bool isSectionHidden (int logicalIndex) const
 Returns true if the section specified by logicalIndex is explicitly hidden from the user; otherwise returns false.
 
void setSectionHidden (int logicalIndex, bool hide)
 If hide is true the section specified by logicalIndex is hidden; otherwise the section is shown.
 
int hiddenSectionCount () const
 
void hideSection (int logicalIndex)
 Hides the section specified by logicalIndex.
 
void showSection (int logicalIndex)
 Shows the section specified by logicalIndex.
 
int count () const
 Returns the number of sections in the header.
 
int visualIndex (int logicalIndex) const
 Returns the visual index position of the section specified by the given logicalIndex, or -1 otherwise.
 
int logicalIndex (int visualIndex) const
 Returns the logicalIndex for the section at the given visualIndex position, or -1 if visualIndex < 0 or visualIndex >= QHeaderView::count().
 
void setSectionsMovable (bool movable)
 Sets \l sectionsMovable to movable.
 
bool sectionsMovable () const
 Returns \l sectionsMovable.
 
void setFirstSectionMovable (bool movable)
 
bool isFirstSectionMovable () const
 
void setSectionsClickable (bool clickable)
 Set \l sectionsClickable to clickable.
 
bool sectionsClickable () const
 Returns \l sectionsClickable.
 
void setHighlightSections (bool highlight)
 
bool highlightSections () const
 
ResizeMode sectionResizeMode (int logicalIndex) const
 
void setSectionResizeMode (ResizeMode mode)
 
void setSectionResizeMode (int logicalIndex, ResizeMode mode)
 
void setResizeContentsPrecision (int precision)
 
int resizeContentsPrecision () const
 
int stretchSectionCount () const
 
void setSortIndicatorShown (bool show)
 
bool isSortIndicatorShown () const
 
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.
 
int sortIndicatorSection () const
 Returns the logical index of the section that has a sort indicator.
 
Qt::SortOrder sortIndicatorOrder () const
 Returns the order for the sort indicator.
 
void setSortIndicatorClearable (bool clearable)
 
bool isSortIndicatorClearable () const
 
bool stretchLastSection () const
 
void setStretchLastSection (bool stretch)
 
bool cascadingSectionResizes () const
 
void setCascadingSectionResizes (bool enable)
 
int defaultSectionSize () const
 
void setDefaultSectionSize (int size)
 
void resetDefaultSectionSize ()
 
int minimumSectionSize () const
 
void setMinimumSectionSize (int size)
 
int maximumSectionSize () const
 
void setMaximumSectionSize (int size)
 
Qt::Alignment defaultAlignment () const
 
void setDefaultAlignment (Qt::Alignment alignment)
 
void doItemsLayout () override
 
bool sectionsMoved () const
 Returns true if sections in the header has been moved; otherwise returns false;.
 
bool sectionsHidden () const
 
QByteArray saveState () const
 
bool restoreState (const QByteArray &state)
 
void reset () override
 \reimp
 
- Public Member Functions inherited from QAbstractItemView
 QAbstractItemView (QWidget *parent=nullptr)
 Constructs an abstract item view with the given parent.
 
 ~QAbstractItemView ()
 Destroys the view.
 
QAbstractItemModelmodel () const
 Returns the model that this view is presenting.
 
virtual void setSelectionModel (QItemSelectionModel *selectionModel)
 Sets the current selection model to the given selectionModel.
 
QItemSelectionModelselectionModel () const
 Returns the current selection model.
 
void setItemDelegate (QAbstractItemDelegate *delegate)
 Sets the item delegate for this view and its model to delegate.
 
QAbstractItemDelegateitemDelegate () const
 Returns the item delegate used by this view and model.
 
void setSelectionMode (QAbstractItemView::SelectionMode mode)
 
QAbstractItemView::SelectionMode selectionMode () const
 
void setSelectionBehavior (QAbstractItemView::SelectionBehavior behavior)
 
QAbstractItemView::SelectionBehavior selectionBehavior () const
 
QModelIndex currentIndex () const
 Returns the model index of the current item.
 
QModelIndex rootIndex () const
 Returns the model index of the model's root item.
 
void setEditTriggers (EditTriggers triggers)
 
EditTriggers editTriggers () const
 
void setVerticalScrollMode (ScrollMode mode)
 
ScrollMode verticalScrollMode () const
 
void resetVerticalScrollMode ()
 
void setHorizontalScrollMode (ScrollMode mode)
 
ScrollMode horizontalScrollMode () const
 
void resetHorizontalScrollMode ()
 
void setAutoScroll (bool enable)
 
bool hasAutoScroll () const
 
void setAutoScrollMargin (int margin)
 
int autoScrollMargin () const
 
void setTabKeyNavigation (bool enable)
 
bool tabKeyNavigation () const
 
void setAlternatingRowColors (bool enable)
 
bool alternatingRowColors () const
 
void setIconSize (const QSize &size)
 
QSize iconSize () const
 
void setTextElideMode (Qt::TextElideMode mode)
 
Qt::TextElideMode textElideMode () const
 
virtual void keyboardSearch (const QString &search)
 Moves to and selects the item best matching the string search.
 
QSize sizeHintForIndex (const QModelIndex &index) const
 Returns the size hint for the item with the specified index or an invalid size for invalid indexes.
 
virtual int sizeHintForRow (int row) const
 Returns the height size hint for the specified row or -1 if there is no model.
 
virtual int sizeHintForColumn (int column) const
 Returns the width size hint for the specified column or -1 if there is no model.
 
void openPersistentEditor (const QModelIndex &index)
 Opens a persistent editor on the item at the given index.
 
void closePersistentEditor (const QModelIndex &index)
 Closes the persistent editor for the item at the given index.
 
bool isPersistentEditorOpen (const QModelIndex &index) const
 
void setIndexWidget (const QModelIndex &index, QWidget *widget)
 
QWidgetindexWidget (const QModelIndex &index) const
 
void setItemDelegateForRow (int row, QAbstractItemDelegate *delegate)
 
QAbstractItemDelegateitemDelegateForRow (int row) const
 
void setItemDelegateForColumn (int column, QAbstractItemDelegate *delegate)
 
QAbstractItemDelegateitemDelegateForColumn (int column) const
 
virtual QAbstractItemDelegateitemDelegateForIndex (const QModelIndex &index) const
 
virtual QVariant inputMethodQuery (Qt::InputMethodQuery query) const override
 \reimp
 

Protected Slots

void updateSection (int logicalIndex)
 
void resizeSections ()
 Resizes the sections according to their size hints.
 
void sectionsInserted (const QModelIndex &parent, int logicalFirst, int logicalLast)
 This slot is called when sections are inserted into the parent.
 
void sectionsAboutToBeRemoved (const QModelIndex &parent, int logicalFirst, int logicalLast)
 This slot is called when sections are removed from the parent.
 
- Protected Slots inherited from QAbstractItemView
virtual void rowsAboutToBeRemoved (const QModelIndex &parent, int start, int end)
 This slot is called when rows are about to be removed.
 
virtual void selectionChanged (const QItemSelection &selected, const QItemSelection &deselected)
 This slot is called when the selection is changed.
 
virtual void updateEditorData ()
 
virtual void updateEditorGeometries ()
 
virtual void verticalScrollbarAction (int action)
 
virtual void horizontalScrollbarAction (int action)
 
virtual void verticalScrollbarValueChanged (int value)
 
virtual void horizontalScrollbarValueChanged (int value)
 
virtual void closeEditor (QWidget *editor, QAbstractItemDelegate::EndEditHint hint)
 Closes the given editor, and releases it.
 
virtual void commitData (QWidget *editor)
 Commit the data in the editor to the model.
 
virtual void editorDestroyed (QObject *editor)
 This function is called when the given editor has been destroyed.
 

Protected Member Functions

 QHeaderView (QHeaderViewPrivate &dd, Qt::Orientation orientation, QWidget *parent=nullptr)
 
void initialize ()
 
void initializeSections ()
 
void initializeSections (int start, int end)
 
void currentChanged (const QModelIndex &current, const QModelIndex &old) override
 \reimp
 
bool event (QEvent *e) override
 \reimp
 
void paintEvent (QPaintEvent *e) override
 \reimp
 
void mousePressEvent (QMouseEvent *e) override
 \reimp
 
void mouseMoveEvent (QMouseEvent *e) override
 \reimp
 
void mouseReleaseEvent (QMouseEvent *e) override
 \reimp
 
void mouseDoubleClickEvent (QMouseEvent *e) override
 \reimp
 
bool viewportEvent (QEvent *e) override
 \reimp
 
virtual void paintSection (QPainter *painter, const QRect &rect, int logicalIndex) const
 Paints the section specified by the given logicalIndex, using the given painter and rect.
 
virtual QSize sectionSizeFromContents (int logicalIndex) const
 Returns the size of the contents of the section specified by the given logicalIndex.
 
int horizontalOffset () const override
 Returns the horizontal offset of the header.
 
int verticalOffset () const override
 Returns the vertical offset of the header.
 
void updateGeometries () override
 \reimp
 
void scrollContentsBy (int dx, int dy) override
 \reimp
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >()) override
 \reimp
 
void rowsInserted (const QModelIndex &parent, int start, int end) override
 \reimp
 
QRect visualRect (const QModelIndex &index) const override
 \reimp
 
void scrollTo (const QModelIndex &index, ScrollHint hint) override
 \reimp
 
QModelIndex indexAt (const QPoint &p) const override
 \reimp
 
bool isIndexHidden (const QModelIndex &index) const override
 \reimp
 
QModelIndex moveCursor (CursorAction, Qt::KeyboardModifiers) override
 \reimp
 
void setSelection (const QRect &rect, QItemSelectionModel::SelectionFlags flags) override
 \reimp
 
QRegion visualRegionForSelection (const QItemSelection &selection) const override
 
virtual void initStyleOptionForIndex (QStyleOptionHeader *option, int logicalIndex) const
 
virtual void initStyleOption (QStyleOptionHeader *option) const
 Initialize option with the values from this QHeaderView.
 
- Protected Member Functions inherited from QAbstractItemView
 QAbstractItemView (QAbstractItemViewPrivate &, QWidget *parent=nullptr)
 
virtual QModelIndexList selectedIndexes () const
 This convenience function returns a list of all selected and non-hidden item indexes in the view.
 
virtual bool edit (const QModelIndex &index, EditTrigger trigger, QEvent *event)
 Starts editing the item at index, creating an editor if necessary, and returns true if the view's \l{State} is now EditingState; otherwise returns false.
 
virtual QItemSelectionModel::SelectionFlags selectionCommand (const QModelIndex &index, const QEvent *event=nullptr) const
 Returns the SelectionFlags to be used when updating a selection model for the specified index.
 
virtual void initViewItemOption (QStyleOptionViewItem *option) const
 
State state () const
 Returns the item view's state.
 
void setState (State state)
 Sets the item view's state to the given state.
 
void scheduleDelayedItemsLayout ()
 Schedules a layout of the items in the view to be executed when the event processing starts.
 
void executeDelayedItemsLayout ()
 Executes the scheduled layouts without waiting for the event processing to begin.
 
void setDirtyRegion (const QRegion &region)
 
void scrollDirtyRegion (int dx, int dy)
 Prepares the view for scrolling by ({dx},{dy}) pixels by moving the dirty regions in the opposite direction.
 
QPoint dirtyRegionOffset () const
 Returns the offset of the dirty regions in the view.
 
void startAutoScroll ()
 
void stopAutoScroll ()
 
void doAutoScroll ()
 
bool focusNextPrevChild (bool next) override
 \reimp
 
bool event (QEvent *event) override
 \reimp
 
bool viewportEvent (QEvent *event) override
 This function is used to handle tool tips, and What's This? mode, if the given event is a QEvent::ToolTip,or a QEvent::WhatsThis.
 
void mousePressEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse button is pressed while the cursor is inside the widget.
 
void mouseMoveEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse move event is sent to the widget.
 
void mouseReleaseEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse button is released, after a mouse press event on the widget.
 
void mouseDoubleClickEvent (QMouseEvent *event) override
 This function is called with the given event when a mouse button is double clicked inside the widget.
 
void focusInEvent (QFocusEvent *event) override
 This function is called with the given event when the widget obtains the focus.
 
void focusOutEvent (QFocusEvent *event) override
 This function is called with the given event when the widget loses the focus.
 
void keyPressEvent (QKeyEvent *event) override
 This function is called with the given event when a key event is sent to the widget.
 
void resizeEvent (QResizeEvent *event) override
 This function is called with the given event when a resize event is sent to the widget.
 
void timerEvent (QTimerEvent *event) override
 This function is called with the given event when a timer event is sent to the widget.
 
void inputMethodEvent (QInputMethodEvent *event) override
 \reimp
 
bool eventFilter (QObject *object, QEvent *event) override
 \reimp
 
QSize viewportSizeHint () const override
 

Properties

bool firstSectionMovable
 Whether the first column can be moved by the user.
 
bool showSortIndicator
 whether the sort indicator is shown
 
bool sectionsMovable
 If sectionsMovable is true, the header sections may be moved by the user; otherwise they are fixed in place.
 
bool sectionsClickable
 Holds true if the header is clickable; otherwise false.
 
bool highlightSections
 whether the sections containing selected items are highlighted
 
bool stretchLastSection
 whether the last visible section in the header takes up all the available space
 
bool cascadingSectionResizes
 whether interactive resizing will be cascaded to the following sections once the section being resized by the user has reached its minimum size
 
int defaultSectionSize
 the default size of the header sections before resizing.
 
int minimumSectionSize
 the minimum size of the header sections.
 
int maximumSectionSize
 the maximum size of the header sections.
 
Qt::Alignment defaultAlignment
 the default alignment of the text in each header section
 
bool sortIndicatorClearable
 Whether the sort indicator can be cleared by clicking on a section multiple times.
 
- Properties inherited from QAbstractItemView
bool autoScroll
 whether autoscrolling in drag move events is enabled
 
int autoScrollMargin
 the size of the area when auto scrolling is triggered
 
EditTriggers editTriggers
 which actions will initiate item editing
 
bool tabKeyNavigation
 whether item navigation with tab and backtab is enabled.
 
bool alternatingRowColors
 whether to draw the background using alternating colors
 
SelectionMode selectionMode
 which selection mode the view operates in
 
SelectionBehavior selectionBehavior
 which selection behavior the view uses
 
QSize iconSize
 the size of items' icons
 
Qt::TextElideMode textElideMode
 the position of the "..." in elided text.
 
ScrollMode verticalScrollMode
 how the view scrolls its contents in the vertical direction
 
ScrollMode horizontalScrollMode
 how the view scrolls its contents in the horizontal direction
 

Private Member Functions

void initStyleOption (QStyleOptionFrame *option) const override
 

Friends

class QTableView
 
class QTreeView
 

Additional Inherited Members

- Protected Types inherited from QAbstractItemView
enum  CursorAction {
  MoveUp , MoveDown , MoveLeft , MoveRight ,
  MoveHome , MoveEnd , MovePageUp , MovePageDown ,
  MoveNext , MovePrevious
}
 This enum describes the different ways to navigate between items,. More...
 
enum  State {
  NoState , DraggingState , DragSelectingState , EditingState ,
  ExpandingState , CollapsingState , AnimatingState
}
 Describes the different states the view can be in. More...
 

Detailed Description

The QHeaderView class provides a header row or header column for item views.

\inmodule QtWidgets

A QHeaderView displays the headers used in item views such as the QTableView and QTreeView classes. It takes the place of Qt3's 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 \l{Model/View Classes} and is part of Qt's \l{Model/View Programming}{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.

Definition at line 17 of file qheaderview.h.

Member Enumeration Documentation

◆ ResizeMode

The resize mode specifies the behavior of the header sections.

It can be set on the entire header view or on individual sections using setSectionResizeMode().

\value Interactive The user can resize the section. The section can also be resized programmatically using resizeSection(). The section size defaults to \l defaultSectionSize. (See also \l cascadingSectionResizes.)

\value Fixed The user cannot resize the section. The section can only be resized programmatically using resizeSection(). The section size defaults to \l defaultSectionSize.

\value Stretch QHeaderView will automatically resize the section to fill the available space. The size cannot be changed by the user or programmatically.

\value ResizeToContents QHeaderView will automatically resize the section to its optimal size based on the contents of the entire column or row. The size cannot be changed by the user or programmatically. (This value was introduced in 4.2)

The following values are obsolete: \value Custom Use Fixed instead.

See also
setSectionResizeMode(), stretchLastSection, minimumSectionSize
Enumerator
Interactive 
Stretch 
Fixed 
ResizeToContents 
Custom 

Definition at line 38 of file qheaderview.h.

Constructor & Destructor Documentation

◆ QHeaderView() [1/2]

QHeaderView::QHeaderView ( Qt::Orientation orientation,
QWidget * parent = nullptr )
explicit

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

Definition at line 272 of file qheaderview.cpp.

References d, initialize(), and orientation().

+ Here is the call graph for this function:

◆ ~QHeaderView()

QHeaderView::~QHeaderView ( )
virtual

Destroys the header.

Definition at line 296 of file qheaderview.cpp.

References d.

◆ QHeaderView() [2/2]

QHeaderView::QHeaderView ( QHeaderViewPrivate & dd,
Qt::Orientation orientation,
QWidget * parent = nullptr )
protected

Definition at line 283 of file qheaderview.cpp.

References d, initialize(), and orientation().

+ Here is the call graph for this function:

Member Function Documentation

◆ cascadingSectionResizes()

bool QHeaderView::cascadingSectionResizes ( ) const

Definition at line 1484 of file qheaderview.cpp.

References d.

◆ count()

int QHeaderView::count ( ) const

◆ currentChanged()

void QHeaderView::currentChanged ( const QModelIndex & current,
const QModelIndex & old )
overrideprotectedvirtual

\reimp

Reimplemented from QAbstractItemView.

Definition at line 2318 of file qheaderview.cpp.

References QModelIndex::column(), d, Qt::Horizontal, QModelIndex::isValid(), QModelIndex::parent(), QModelIndex::row(), sectionSize(), sectionViewportPosition(), and Qt::Vertical.

+ Here is the call graph for this function:

◆ dataChanged()

void QHeaderView::dataChanged ( const QModelIndex & topLeft,
const QModelIndex & bottomRight,
const QList< int > & roles = QList<int>() )
overrideprotectedvirtual

\reimp

Reimplemented from QAbstractItemView.

Definition at line 3082 of file qheaderview.cpp.

References QModelIndex::column(), d, Qt::DecorationRole, Qt::DisplayRole, Qt::FontRole, Qt::Horizontal, i, orientation(), ResizeToContents, QModelIndex::row(), sectionResizeMode(), Qt::SizeHintRole, and Qt::UserRole.

+ Here is the call graph for this function:

◆ defaultAlignment()

Qt::Alignment QHeaderView::defaultAlignment ( ) const

Definition at line 1643 of file qheaderview.cpp.

References d.

◆ defaultSectionSize()

int QHeaderView::defaultSectionSize ( ) const

Definition at line 1510 of file qheaderview.cpp.

References d.

◆ doItemsLayout()

void QHeaderView::doItemsLayout ( )
overridevirtual

Reimplemented from QAbstractItemView.

Definition at line 1662 of file qheaderview.cpp.

References QAbstractItemView::doItemsLayout(), and initializeSections().

+ Here is the call graph for this function:

◆ event()

bool QHeaderView::event ( QEvent * e)
overrideprotected

\reimp

Definition at line 2344 of file qheaderview.cpp.

References d, QAbstractItemView::event(), QEvent::HoverEnter, QEvent::HoverLeave, QEvent::HoverMove, QEvent::Leave, logicalIndexAt(), resizeSections(), QEvent::StyleChange, QEvent::Timer, QEvent::type(), and updateSection().

+ Here is the call graph for this function:

◆ geometriesChanged

void QHeaderView::geometriesChanged ( )
signal
Since
4.2

This signal is emitted when the header's geometries have changed.

Referenced by QTreeView::setHeader(), QTableView::setHorizontalHeader(), QTableView::setVerticalHeader(), and viewportEvent().

+ Here is the caller graph for this function:

◆ headerDataChanged

void QHeaderView::headerDataChanged ( Qt::Orientation orientation,
int logicalFirst,
int logicalLast )
slot

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

Definition at line 1773 of file qheaderview.cpp.

References count(), d, Qt::Horizontal, orientation(), qMax(), qMin(), and visualIndex().

Referenced by setModel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hiddenSectionCount()

int QHeaderView::hiddenSectionCount ( ) const
Since
4.1

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

See also
setSectionHidden(), isSectionHidden()

Definition at line 949 of file qheaderview.cpp.

References d.

◆ hideSection()

void QHeaderView::hideSection ( int logicalIndex)
inline

Hides the section specified by logicalIndex.

See also
showSection(), isSectionHidden(), hiddenSectionCount(), setSectionHidden()

Definition at line 224 of file qheaderview.h.

References setSectionHidden().

+ Here is the call graph for this function:

◆ highlightSections()

bool QHeaderView::highlightSections ( ) const

Definition at line 1159 of file qheaderview.cpp.

References d.

◆ horizontalOffset()

int QHeaderView::horizontalOffset ( ) const
overrideprotectedvirtual

Returns the horizontal offset of the header.

This is 0 for vertical headers.

See also
offset()

Implements QAbstractItemView.

Definition at line 3031 of file qheaderview.cpp.

References d, and Qt::Horizontal.

◆ indexAt()

QModelIndex QHeaderView::indexAt ( const QPoint & p) const
overrideprotectedvirtual

\reimp

Empty implementation because the header doesn't show QModelIndex items.

Implements QAbstractItemView.

Definition at line 3156 of file qheaderview.cpp.

◆ initialize()

void QHeaderView::initialize ( )
protected

Definition at line 305 of file qheaderview.cpp.

References QPalette::Button, d, Qt::ElideNone, Qt::NoFocus, Qt::ScrollBarAlwaysOff, and setFrameStyle().

Referenced by QHeaderView(), and QHeaderView().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initializeSections() [1/2]

void QHeaderView::initializeSections ( )
protected

Definition at line 2221 of file qheaderview.cpp.

References d, emit, initializeSections(), qBound(), sectionCountChanged(), and stretchLastSection.

Referenced by doItemsLayout(), initializeSections(), reset(), setModel(), and setSectionResizeMode().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initializeSections() [2/2]

void QHeaderView::initializeSections ( int start,
int end )
protected

Definition at line 2246 of file qheaderview.cpp.

References QSet< T >::begin(), d, emit, QSet< T >::end(), QSet< T >::erase(), i, it, j, Q_ASSERT, ResizeToContents, sectionCountChanged(), and Stretch.

+ Here is the call graph for this function:

◆ initStyleOption() [1/2]

void QHeaderView::initStyleOption ( QStyleOptionFrame * option) const
overrideprivate

Definition at line 3417 of file qheaderview.cpp.

References QFrame::initStyleOption().

+ Here is the call graph for this function:

◆ initStyleOption() [2/2]

void QHeaderView::initStyleOption ( QStyleOptionHeader * option) const
protectedvirtual

Initialize option with the values from this QHeaderView.

This method is useful for subclasses when they need a QStyleOptionHeader, but do not want to fill in all the information themselves.

See also
QStyleOption::initFrom(), initStyleOptionForIndex()

Definition at line 3404 of file qheaderview.cpp.

References d, Qt::Horizontal, QStyle::State_Enabled, QStyle::State_Horizontal, QStyle::State_None, and QStyle::State_Raised.

Referenced by paintSection(), and sectionSizeFromContents().

+ Here is the caller graph for this function:

◆ initStyleOptionForIndex()

void QHeaderView::initStyleOptionForIndex ( QStyleOptionHeader * option,
int logicalIndex ) const
protectedvirtual
Since
6.0

Initializes the style option from the specified logicalIndex. This function is called by the default implementation of paintSection after initStyleOption has been called.

See also
paintSection(), initStyleOption()

Definition at line 2849 of file qheaderview.cpp.

References Qt::AlignVCenter, Qt::AscendingOrder, Qt::BackgroundRole, QStyleOptionHeader::Beginning, QPalette::Button, QPalette::ButtonText, QVariant::canConvert(), d, Qt::DecorationRole, Qt::DisplayRole, QStyleOptionHeader::End, QStyleOption::fontMetrics, Qt::FontRole, Qt::ForegroundRole, QStyleOptionButton::icon, QIcon::isNull(), isSortIndicatorShown(), QVariant::isValid(), logicalIndex(), QStyleOptionHeader::Middle, QStyleOptionHeader::NextAndPreviousAreSelected, QStyleOptionHeader::NextIsSelected, QStyleOptionHeader::NotAdjacent, QStyleOptionHeader::OnlyOneSection, opt, QStyleOption::palette, QStyleOptionHeader::PreviousIsSelected, Q_ASSERT, QPalette::setBrush(), QStyleOptionHeader::SortDown, sortIndicatorOrder(), sortIndicatorSection(), QStyleOptionHeader::SortUp, QAbstractItemView::state(), QStyleOption::state, QStyle::State_Active, QStyle::State_MouseOver, QStyle::State_None, QStyle::State_On, QStyle::State_Sunken, QStyleOptionButton::text, Qt::TextAlignmentRole, var, variant, visualIndex(), QPalette::Window, and window().

Referenced by paintSection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isFirstSectionMovable()

bool QHeaderView::isFirstSectionMovable ( ) const

Definition at line 1120 of file qheaderview.cpp.

References d.

◆ isIndexHidden()

bool QHeaderView::isIndexHidden ( const QModelIndex & index) const
overrideprotectedvirtual

\reimp

Empty implementation because the header doesn't show QModelIndex items.

Implements QAbstractItemView.

Definition at line 3168 of file qheaderview.cpp.

◆ isSectionHidden()

bool QHeaderView::isSectionHidden ( int logicalIndex) const

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

See also
hideSection(), showSection(), setSectionHidden(), hiddenSectionCount()

Definition at line 931 of file qheaderview.cpp.

References d, logicalIndex(), Q_ASSERT, and visualIndex().

Referenced by QTreeViewPrivate::calcLogicalIndices(), QTreeViewPrivate::columnRanges(), QTableViewPrivate::isColumnHidden(), QTableViewPrivate::isRowHidden(), QTableView::paintEvent(), resizeSection(), sectionSize(), sectionSizeHint(), sizeHint(), and QTableViewPrivate::trimHiddenSelections().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSortIndicatorClearable()

bool QHeaderView::isSortIndicatorClearable ( ) const

Definition at line 1427 of file qheaderview.cpp.

References d.

◆ isSortIndicatorShown()

bool QHeaderView::isSortIndicatorShown ( ) const

Definition at line 1323 of file qheaderview.cpp.

References d.

Referenced by initStyleOptionForIndex(), and sectionSizeFromContents().

+ Here is the caller graph for this function:

◆ length()

int QHeaderView::length ( ) const

Returns the length along the orientation of the header.

See also
sizeHint(), setSectionResizeMode(), offset()

Definition at line 460 of file qheaderview.cpp.

References d.

Referenced by QTreeView::drawRow(), QTableView::paintEvent(), setOffsetToLastSection(), QTreeViewPrivate::updateScrollBars(), and QTreeViewPrivate::visualRect().

+ Here is the caller graph for this function:

◆ logicalIndex()

int QHeaderView::logicalIndex ( int visualIndex) const

Returns the logicalIndex for the section at the given visualIndex position, or -1 if visualIndex < 0 or visualIndex >= QHeaderView::count().

Note that the visualIndex is not affected by hidden sections.

See also
visualIndex(), sectionPosition()

Definition at line 1050 of file qheaderview.cpp.

References d, and visualIndex().

Referenced by QTreeViewPrivate::calcLogicalIndices(), QTreeViewPrivate::columnRanges(), QTreeView::drawRow(), initStyleOptionForIndex(), isSectionHidden(), logicalIndexAt(), QTreeViewPrivate::logicalIndexForTree(), mouseMoveEvent(), moveSection(), paintEvent(), QTableView::paintEvent(), paintSection(), sectionPosition(), sectionResizeMode(), sectionSize(), sectionSizeFromContents(), sectionSizeHint(), sectionViewportPosition(), setMaximumSectionSize(), setMinimumSectionSize(), setSectionHidden(), setSectionResizeMode(), setSortIndicator(), QTreeViewPrivate::updateScrollBars(), updateSection(), visualIndex(), and visualRegionForSelection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ logicalIndexAt() [1/3]

int QHeaderView::logicalIndexAt ( const QPoint & pos) const
inline

Returns the logical index of the section at the position given in pos.

If the header is horizontal the x-coordinate will be used, otherwise the y-coordinate will be used to find the logical index.

See also
sectionPosition()

Definition at line 222 of file qheaderview.h.

References logicalIndexAt().

+ Here is the call graph for this function:

◆ logicalIndexAt() [2/3]

int QHeaderView::logicalIndexAt ( int position) const

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

See also
visualIndexAt(), isSectionHidden()

Definition at line 585 of file qheaderview.cpp.

References logicalIndex(), position(), and visualIndexAt().

Referenced by QTreeViewPrivate::columnAt(), event(), QTreeViewPrivate::itemDecorationAt(), logicalIndexAt(), logicalIndexAt(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), QTableViewPrivate::selectColumn(), QTableViewPrivate::selectRow(), viewportEvent(), and QTreeWidget::visualItemRect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ logicalIndexAt() [3/3]

int QHeaderView::logicalIndexAt ( int x,
int y ) const
inline

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.

Definition at line 220 of file qheaderview.h.

References Qt::Horizontal, logicalIndexAt(), and orientation().

+ Here is the call graph for this function:

◆ maximumSectionSize()

int QHeaderView::maximumSectionSize ( ) const

Definition at line 1598 of file qheaderview.cpp.

References d, and maxSizeSection.

◆ minimumSectionSize()

int QHeaderView::minimumSectionSize ( ) const

Definition at line 1546 of file qheaderview.cpp.

References d, fontMetrics, Qt::Horizontal, and QStyle::PM_HeaderMargin.

◆ mouseDoubleClickEvent()

void QHeaderView::mouseDoubleClickEvent ( QMouseEvent * e)
overrideprotected

\reimp

Definition at line 2734 of file qheaderview.cpp.

References Qt::ArrowCursor, cursor, d, emit, Qt::Horizontal, Interactive, logicalIndexAt(), pos, QSinglePointEvent::position(), sectionDoubleClicked(), sectionHandleDoubleClicked(), sectionResizeMode(), setCursor(), Qt::SplitHCursor, Qt::SplitVCursor, and QPointF::toPoint().

+ Here is the call graph for this function:

◆ mouseMoveEvent()

◆ mousePressEvent()

void QHeaderView::mousePressEvent ( QMouseEvent * e)
overrideprotected

\reimp

Definition at line 2498 of file qheaderview.cpp.

References QSinglePointEvent::button(), d, emit, Qt::Horizontal, Interactive, Qt::LeftButton, logicalIndexAt(), QHeaderViewPrivate::MoveSection, QHeaderViewPrivate::NoState, pos, QSinglePointEvent::position(), QHeaderViewPrivate::ResizeSection, sectionPressed(), sectionResizeMode(), sectionSize(), QHeaderViewPrivate::SelectSections, QPointF::toPoint(), and updateSection().

+ Here is the call graph for this function:

◆ mouseReleaseEvent()

void QHeaderView::mouseReleaseEvent ( QMouseEvent * e)
overrideprotected

◆ moveCursor()

QModelIndex QHeaderView::moveCursor ( CursorAction ,
Qt::KeyboardModifiers  )
overrideprotectedvirtual

\reimp

Empty implementation because the header doesn't show QModelIndex items.

Implements QAbstractItemView.

Definition at line 3180 of file qheaderview.cpp.

◆ moveSection()

void QHeaderView::moveSection ( int from,
int to )

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

See also
sectionsMoved()

Definition at line 699 of file qheaderview.cpp.

References d, emit, logicalIndex(), Q_ASSERT, qMoveRange(), sectionMoved(), stretchLastSection, updateSection(), and visualIndex().

Referenced by mouseReleaseEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ offset()

int QHeaderView::offset ( ) const

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

See also
setOffset()

Definition at line 387 of file qheaderview.cpp.

References d.

Referenced by QTreeView::drawRow(), and QTableView::paintEvent().

+ Here is the caller graph for this function:

◆ orientation()

Qt::Orientation QHeaderView::orientation ( ) const

Returns the orientation of the header.

See also
Qt::Orientation

Definition at line 374 of file qheaderview.cpp.

References d.

Referenced by QHeaderView(), QHeaderView(), dataChanged(), headerDataChanged(), and logicalIndexAt().

+ Here is the caller graph for this function:

◆ paintEvent()

◆ paintSection()

void QHeaderView::paintSection ( QPainter * painter,
const QRect & rect,
int logicalIndex ) const
protectedvirtual

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

Normally, you do not have to call this function.

Definition at line 2951 of file qheaderview.cpp.

References QPalette::brush(), QPainter::brushOrigin(), QPalette::Button, QStyle::CE_Header, initStyleOption(), initStyleOptionForIndex(), logicalIndex(), opt, painter, QStyleOption::palette, rect, QStyleOption::rect, QPainter::setBrushOrigin(), QRect::topLeft(), and QPalette::Window.

Referenced by paintEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset()

void QHeaderView::reset ( )
overridevirtual

\reimp

Reimplemented from QAbstractItemView.

Definition at line 1758 of file qheaderview.cpp.

References d, initializeSections(), and QAbstractItemView::reset().

+ Here is the call graph for this function:

◆ resetDefaultSectionSize()

void QHeaderView::resetDefaultSectionSize ( )

Definition at line 1524 of file qheaderview.cpp.

References d.

◆ resizeContentsPrecision()

int QHeaderView::resizeContentsPrecision ( ) const
Since
5.2 Returns how precise QHeaderView will calculate on ResizeToContents.
See also
setResizeContentsPrecision(), setSectionResizeMode()

Definition at line 1275 of file qheaderview.cpp.

References d.

◆ resizeSection()

void QHeaderView::resizeSection ( int logicalIndex,
int size )

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

The size parameter must be a value larger or equal to zero. A size equal to zero is however not recommended. In that situation hideSection should be used instead.

See also
sectionResized(), sectionSize(), hideSection()

Definition at line 822 of file qheaderview.cpp.

References count(), d, emit, Qt::Horizontal, isSectionHidden(), maximumSectionSize, maxSizeSection, minimumSectionSize, pos, qBound(), QHeaderViewPrivate::ResizeSection, sectionResized(), sectionViewportPosition(), QRect::setRect(), stretchLastSection, and visualIndex().

Referenced by mouseMoveEvent(), setMaximumSectionSize(), setMinimumSectionSize(), and setSectionHidden().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resizeSections [1/2]

void QHeaderView::resizeSections ( )
protectedslot

Resizes the sections according to their size hints.

Normally, you do not have to call this function.

Definition at line 1827 of file qheaderview.cpp.

References d, and Interactive.

Referenced by event(), setSortIndicator(), setSortIndicatorShown(), setStretchLastSection(), and viewportEvent().

+ Here is the caller graph for this function:

◆ resizeSections() [2/2]

void QHeaderView::resizeSections ( QHeaderView::ResizeMode mode)

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

See also
sectionResized()

Definition at line 902 of file qheaderview.cpp.

References d.

◆ restoreState()

bool QHeaderView::restoreState ( const QByteArray & state)
Since
4.3 Restores the state of this header view. This function returns true if the state was restored; otherwise returns false.
See also
saveState()

Definition at line 1724 of file qheaderview.cpp.

References d, emit, QIODeviceBase::ReadOnly, sortIndicatorChanged(), QAbstractItemView::state(), and QHeaderViewPrivate::VersionMarker.

+ Here is the call graph for this function:

◆ rowsInserted()

void QHeaderView::rowsInserted ( const QModelIndex & parent,
int start,
int end )
overrideprotectedvirtual

\reimp

Empty implementation because the header doesn't show QModelIndex items.

Reimplemented from QAbstractItemView.

Definition at line 3120 of file qheaderview.cpp.

◆ saveState()

QByteArray QHeaderView::saveState ( ) const
Since
4.3

Saves the current state of this header view.

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

See also
restoreState()

Definition at line 1704 of file qheaderview.cpp.

References d, QHeaderViewPrivate::VersionMarker, and QIODeviceBase::WriteOnly.

◆ scrollContentsBy()

void QHeaderView::scrollContentsBy ( int dx,
int dy )
overrideprotected

\reimp

Definition at line 3072 of file qheaderview.cpp.

References d.

◆ scrollTo()

void QHeaderView::scrollTo ( const QModelIndex & index,
ScrollHint hint )
overrideprotectedvirtual

\reimp

Empty implementation because the header doesn't show QModelIndex items.

Implements QAbstractItemView.

Definition at line 3144 of file qheaderview.cpp.

◆ sectionClicked

void QHeaderView::sectionClicked ( int logicalIndex)
signal

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
setSectionsClickable(), sectionPressed()

Referenced by mouseReleaseEvent().

+ Here is the caller graph for this function:

◆ sectionCountChanged

void QHeaderView::sectionCountChanged ( int oldCount,
int newCount )
signal

This signal is emitted when the number of sections changes, i.e., when sections are added or deleted.

The original count is specified by oldCount, and the new count by newCount.

See also
count(), length(), headerDataChanged()

Referenced by initializeSections(), initializeSections(), sectionsInserted(), QTreeView::setHeader(), QTableView::setHorizontalHeader(), and QTableView::setVerticalHeader().

+ Here is the caller graph for this function:

◆ sectionDoubleClicked

void QHeaderView::sectionDoubleClicked ( int logicalIndex)
signal

This signal is emitted when a section is double-clicked.

The section's logical index is specified by logicalIndex.

See also
setSectionsClickable()

Referenced by mouseDoubleClickEvent().

+ Here is the caller graph for this function:

◆ sectionEntered

void QHeaderView::sectionEntered ( int logicalIndex)
signal
Since
4.3

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
setSectionsClickable(), sectionPressed()

Referenced by mouseMoveEvent(), QTableView::setSortingEnabled(), and QTableView::setVerticalHeader().

+ Here is the caller graph for this function:

◆ sectionHandleDoubleClicked

void QHeaderView::sectionHandleDoubleClicked ( int logicalIndex)
signal

This signal is emitted when a section is double-clicked.

The section's logical index is specified by logicalIndex.

See also
setSectionsClickable()

Referenced by mouseDoubleClickEvent(), QTreeView::setHeader(), QTableView::setHorizontalHeader(), and QTableView::setVerticalHeader().

+ Here is the caller graph for this function:

◆ sectionMoved

void QHeaderView::sectionMoved ( int logicalIndex,
int oldVisualIndex,
int newVisualIndex )
signal

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()

Referenced by moveSection(), QTreeView::setHeader(), QTableView::setHorizontalHeader(), QTableView::setVerticalHeader(), and swapSections().

+ Here is the caller graph for this function:

◆ sectionPosition()

int QHeaderView::sectionPosition ( int logicalIndex) const

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

The position is measured in pixels from the first visible item's top-left corner to the top-left corner of the item with logicalIndex. The measurement is along the x-axis for horizontal headers and along the y-axis for vertical headers.

See also
sectionViewportPosition()

Definition at line 625 of file qheaderview.cpp.

References d, logicalIndex(), and visualIndex().

Referenced by QTreeView::drawRow(), and sectionViewportPosition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sectionPressed

void QHeaderView::sectionPressed ( int logicalIndex)
signal

This signal is emitted when a section is pressed.

The section's logical index is specified by logicalIndex.

See also
setSectionsClickable()

Referenced by mousePressEvent(), QTableView::setSortingEnabled(), and QTableView::setVerticalHeader().

+ Here is the caller graph for this function:

◆ sectionResized

void QHeaderView::sectionResized ( int logicalIndex,
int oldSize,
int newSize )
signal

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()

Referenced by resizeSection(), QTreeView::setHeader(), QTableView::setHorizontalHeader(), and QTableView::setVerticalHeader().

+ Here is the caller graph for this function:

◆ sectionResizeMode()

QHeaderView::ResizeMode QHeaderView::sectionResizeMode ( int logicalIndex) const
Since
5.0

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

See also
setSectionResizeMode()

Definition at line 1230 of file qheaderview.cpp.

References d, Fixed, logicalIndex(), and visualIndex().

Referenced by dataChanged(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), and setSortIndicator().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sectionsAboutToBeRemoved

void QHeaderView::sectionsAboutToBeRemoved ( const QModelIndex & parent,
int logicalFirst,
int logicalLast )
protectedslot

This slot is called when sections are removed from the parent.

logicalFirst and logicalLast signify where the sections were removed.

If only one section is removed, logicalFirst and logicalLast will be the same.

Definition at line 1948 of file qheaderview.cpp.

References Q_UNUSED.

Referenced by setModel().

+ Here is the caller graph for this function:

◆ sectionsClickable()

bool QHeaderView::sectionsClickable ( ) const

Returns \l sectionsClickable.

Definition at line 1147 of file qheaderview.cpp.

References d.

◆ sectionsHidden()

bool QHeaderView::sectionsHidden ( ) const
Since
4.1

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

See also
setSectionHidden()

Definition at line 1688 of file qheaderview.cpp.

References d.

Referenced by QTableView::paintEvent().

+ Here is the caller graph for this function:

◆ sectionsInserted

void QHeaderView::sectionsInserted ( const QModelIndex & parent,
int logicalFirst,
int logicalLast )
protectedslot

This slot is called when sections are inserted into the parent.

logicalFirst and logicalLast indices signify where the new sections were inserted.

If only one section is inserted, logicalFirst and logicalLast will be the same.

Definition at line 1843 of file qheaderview.cpp.

References QSet< T >::cbegin(), count(), d, emit, i, it, j, Q_ASSERT, QHeaderViewPrivate::ResizeSection, ResizeToContents, sectionCountChanged(), Stretch, stretchLastSection, and QSet< T >::swap().

Referenced by setModel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sectionSize()

int QHeaderView::sectionSize ( int logicalIndex) const

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

See also
length(), setSectionResizeMode(), defaultSectionSize()

Definition at line 600 of file qheaderview.cpp.

References count(), d, isSectionHidden(), logicalIndex(), and visualIndex().

Referenced by currentChanged(), QTreeView::drawRow(), QTableViewPrivate::intersectedRect(), QTreeViewPrivate::itemDecorationRect(), mousePressEvent(), mouseReleaseEvent(), paintEvent(), QTableView::paintEvent(), sectionViewportPosition(), QTreeViewPrivate::updateScrollBars(), updateSection(), and visualRegionForSelection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sectionSizeFromContents()

QSize QHeaderView::sectionSizeFromContents ( int logicalIndex) const
protectedvirtual

Returns the size of the contents of the section specified by the given logicalIndex.

See also
defaultSectionSize()

Definition at line 2988 of file qheaderview.cpp.

References QVariant::canConvert(), QStyle::CT_HeaderSection, d, Qt::DecorationRole, Qt::DisplayRole, font, QStyleOption::fontMetrics, Qt::FontRole, QStyleOptionButton::icon, initStyleOption(), QIcon::isNull(), isSortIndicatorShown(), QVariant::isValid(), logicalIndex(), opt, Q_ASSERT, QFont::setBold(), Qt::SizeHintRole, QStyleOptionHeader::SortDown, QStyleOptionButton::text, var, and variant.

Referenced by sectionSizeHint(), and sizeHint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sectionSizeHint()

int QHeaderView::sectionSizeHint ( int logicalIndex) const

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

See also
sizeHint(), defaultSectionSize(), minimumSectionSize(), maximumSectionSize() Qt::SizeHintRole

Definition at line 527 of file qheaderview.cpp.

References count(), d, hint(), Qt::Horizontal, isSectionHidden(), logicalIndex(), maximumSectionSize, minimumSectionSize, qBound(), sectionSizeFromContents(), and Qt::SizeHintRole.

Referenced by QTreeView::resizeColumnToContents().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sectionsMovable()

bool QHeaderView::sectionsMovable ( ) const

Returns \l sectionsMovable.

Definition at line 1084 of file qheaderview.cpp.

References d.

◆ sectionsMoved()

bool QHeaderView::sectionsMoved ( ) const

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

See also
moveSection()

Definition at line 1674 of file qheaderview.cpp.

References d.

Referenced by QTableViewPrivate::drawAndClipSpans(), QTreeView::drawRow(), QTableViewPrivate::intersectedRect(), QTableViewPrivate::selectColumn(), QTableViewPrivate::selectRow(), QTableView::setSelection(), and QTableView::visualRegionForSelection().

+ Here is the caller graph for this function:

◆ sectionViewportPosition()

int QHeaderView::sectionViewportPosition ( int logicalIndex) const

Returns the section viewport position of the given logicalIndex.

If the section is hidden, the return value is undefined.

See also
sectionPosition(), isSectionHidden()

Definition at line 645 of file qheaderview.cpp.

References count(), d, logicalIndex(), position(), sectionPosition(), and sectionSize().

Referenced by currentChanged(), QTableViewPrivate::intersectedRect(), QTreeViewPrivate::itemDecorationRect(), mouseReleaseEvent(), paintEvent(), resizeSection(), updateSection(), visualRegionForSelection(), and QTableViewPrivate::visualSpanRect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCascadingSectionResizes()

void QHeaderView::setCascadingSectionResizes ( bool enable)

Definition at line 1490 of file qheaderview.cpp.

References d.

◆ setDefaultAlignment()

void QHeaderView::setDefaultAlignment ( Qt::Alignment alignment)

Definition at line 1649 of file qheaderview.cpp.

References alignment, and d.

Referenced by QTreeViewPrivate::initialize().

+ Here is the caller graph for this function:

◆ setDefaultSectionSize()

void QHeaderView::setDefaultSectionSize ( int size)

Definition at line 1516 of file qheaderview.cpp.

References d, and maxSizeSection.

◆ setFirstSectionMovable()

void QHeaderView::setFirstSectionMovable ( bool movable)

Definition at line 1114 of file qheaderview.cpp.

References d.

Referenced by QTreeView::setHeader().

+ Here is the caller graph for this function:

◆ setHighlightSections()

void QHeaderView::setHighlightSections ( bool highlight)

Definition at line 1153 of file qheaderview.cpp.

References d.

Referenced by QTableViewPrivate::init().

+ Here is the caller graph for this function:

◆ setMaximumSectionSize()

void QHeaderView::setMaximumSectionSize ( int size)

Definition at line 1606 of file qheaderview.cpp.

References d, logicalIndex(), maxSizeSection, minimumSectionSize, and resizeSection().

Referenced by setMinimumSectionSize().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMinimumSectionSize()

void QHeaderView::setMinimumSectionSize ( int size)

Definition at line 1558 of file qheaderview.cpp.

References d, logicalIndex(), maximumSectionSize, maxSizeSection, resizeSection(), and setMaximumSectionSize().

+ Here is the call graph for this function:

◆ setModel()

◆ setOffset

void QHeaderView::setOffset ( int offset)
slot

Sets the header's offset to offset.

See also
offset(), length()

Definition at line 401 of file qheaderview.cpp.

References d, Qt::Horizontal, QCursor::pos(), QHeaderViewPrivate::ResizeSection, QCursor::setPos(), QPoint::x(), and QPoint::y().

Referenced by setOffsetToLastSection(), and setOffsetToSectionPosition().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setOffsetToLastSection

void QHeaderView::setOffsetToLastSection ( )
slot
Since
4.2 Sets the offset to make the last section visible.
See also
setOffset(), sectionPosition(), setOffsetToSectionPosition()

Definition at line 446 of file qheaderview.cpp.

References d, Qt::Horizontal, length(), position(), setOffset(), and viewport().

+ Here is the call graph for this function:

◆ setOffsetToSectionPosition

void QHeaderView::setOffsetToSectionPosition ( int visualSectionNumber)
slot
Since
4.2 Sets the offset to the start of the section at the given visualSectionNumber. visualSectionNumber is the actual visible section when hiddenSections are not considered. That is not always the same as visualIndex().
See also
setOffset(), sectionPosition()

Definition at line 431 of file qheaderview.cpp.

References d, position(), and setOffset().

+ Here is the call graph for this function:

◆ setResizeContentsPrecision()

void QHeaderView::setResizeContentsPrecision ( int precision)
Since
5.2 Sets how precise QHeaderView should calculate the size when ResizeToContents is used. A low value will provide a less accurate but fast auto resize while a higher value will provide a more accurate resize that however can be slow.

The number precision specifies how many sections that should be consider when calculating the preferred size.

The default value is 1000 meaning that a horizontal column with auto-resize will look at maximum 1000 rows on calculating when doing an auto resize.

Special value 0 means that it will look at only the visible area. Special value -1 will imply looking at all elements.

This value is used in QTableView::sizeHintForColumn(), QTableView::sizeHintForRow() and QTreeView::sizeHintForColumn(). Reimplementing these functions can make this function not having an effect.

See also
resizeContentsPrecision(), setSectionResizeMode(), resizeSections(), QTableView::sizeHintForColumn(), QTableView::sizeHintForRow(), QTreeView::sizeHintForColumn()

Definition at line 1261 of file qheaderview.cpp.

References d.

◆ setSectionHidden()

void QHeaderView::setSectionHidden ( int logicalIndex,
bool hide )

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

See also
isSectionHidden(), hiddenSectionCount()

Definition at line 962 of file qheaderview.cpp.

References count(), d, hide(), logicalIndex(), Q_ASSERT, resizeSection(), stretchLastSection, and visualIndex().

Referenced by hideSection(), and showSection().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSectionResizeMode() [1/2]

void QHeaderView::setSectionResizeMode ( int logicalIndex,
ResizeMode mode )
Since
5.0

Sets the constraints on how the section specified by logicalIndex in the header can be resized to those described by the given mode. The logical index should exist at the time this function is called.

Note
This setting will be ignored for the last section if the stretchLastSection property is set to true. This is the default for the horizontal headers provided by QTreeView.
See also
setStretchLastSection(), resizeContentsPrecision()

Definition at line 1199 of file qheaderview.cpp.

References d, logicalIndex(), QHeaderViewPrivate::NoState, Q_ASSERT, ResizeToContents, Stretch, and visualIndex().

+ Here is the call graph for this function:

◆ setSectionResizeMode() [2/2]

void QHeaderView::setSectionResizeMode ( ResizeMode mode)
Since
5.0

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

See also
length(), sectionResized()

Definition at line 1174 of file qheaderview.cpp.

References count(), d, initializeSections(), ResizeToContents, and Stretch.

+ Here is the call graph for this function:

◆ setSectionsClickable()

void QHeaderView::setSectionsClickable ( bool clickable)

Set \l sectionsClickable to clickable.

Definition at line 1138 of file qheaderview.cpp.

References d.

Referenced by QTreeWidget::QTreeWidget(), QTableViewPrivate::init(), and QTreeView::setSortingEnabled().

+ Here is the caller graph for this function:

◆ setSectionsMovable()

void QHeaderView::setSectionsMovable ( bool movable)

Sets \l sectionsMovable to movable.

Definition at line 1075 of file qheaderview.cpp.

References d.

Referenced by QTreeViewPrivate::initialize().

+ Here is the caller graph for this function:

◆ setSelection()

void QHeaderView::setSelection ( const QRect & rect,
QItemSelectionModel::SelectionFlags flags )
overrideprotectedvirtual

\reimp

Selects the items in the given rect according to the specified flags.

The base class implementation does nothing.

Implements QAbstractItemView.

Definition at line 3194 of file qheaderview.cpp.

◆ setSortIndicator()

void QHeaderView::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.

logicalIndex may be -1, in which case no sort indicator will be shown and the model will return to its natural, unsorted order. Note that not all models support this and may even crash in this case.

See also
sortIndicatorSection(), sortIndicatorOrder()

Definition at line 1341 of file qheaderview.cpp.

References d, emit, logicalIndex(), resizeSections(), ResizeToContents, sectionResizeMode(), sortIndicatorChanged(), and updateSection().

Referenced by QFileDialogTreeView::setFileDialogPrivate(), QTreeWidget::sortItems(), and QTableWidget::sortItems().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setSortIndicatorClearable()

void QHeaderView::setSortIndicatorClearable ( bool clearable)

Definition at line 1418 of file qheaderview.cpp.

References d, emit, and sortIndicatorClearableChanged().

+ Here is the call graph for this function:

◆ setSortIndicatorShown()

void QHeaderView::setSortIndicatorShown ( bool show)

Definition at line 1306 of file qheaderview.cpp.

References count(), d, resizeSections(), ResizeToContents, show(), and sortIndicatorSection().

Referenced by QTableView::setSortingEnabled(), and QTreeView::setSortingEnabled().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setStretchLastSection()

void QHeaderView::setStretchLastSection ( bool stretch)

Definition at line 1454 of file qheaderview.cpp.

References d, QHeaderViewPrivate::NoState, and resizeSections().

Referenced by QTreeViewPrivate::initialize(), and QFileDialogTreeView::setFileDialogPrivate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setVisible()

void QHeaderView::setVisible ( bool v)
override

\reimp

Definition at line 508 of file qheaderview.cpp.

References isVisible().

Referenced by QtPrivate::QCalendarView::QCalendarView().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showSection()

void QHeaderView::showSection ( int logicalIndex)
inline

Shows the section specified by logicalIndex.

See also
hideSection(), isSectionHidden(), hiddenSectionCount(), setSectionHidden()

Definition at line 226 of file qheaderview.h.

References setSectionHidden().

+ Here is the call graph for this function:

◆ sizeHint()

QSize QHeaderView::sizeHint ( ) const
override

Returns a suitable size hint for this header.

See also
sectionSizeHint()

Definition at line 475 of file qheaderview.cpp.

References count(), d, hint(), i, isSectionHidden(), j, qMax(), and sectionSizeFromContents().

Referenced by QFileDialogTreeView::sizeHint().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sortIndicatorChanged

void QHeaderView::sortIndicatorChanged ( int logicalIndex,
Qt::SortOrder order )
signal
Since
4.3

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()

Referenced by restoreState(), setSortIndicator(), QTableView::setSortingEnabled(), and QTreeView::setSortingEnabled().

+ Here is the caller graph for this function:

◆ sortIndicatorClearableChanged

void QHeaderView::sortIndicatorClearableChanged ( bool clearable)
signal

Referenced by setSortIndicatorClearable().

+ Here is the caller graph for this function:

◆ sortIndicatorOrder()

Qt::SortOrder QHeaderView::sortIndicatorOrder ( ) const

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(), sortIndicatorSection()

Definition at line 1392 of file qheaderview.cpp.

References d.

Referenced by QTableWidgetPrivate::dataChanged(), QTreeWidgetPrivate::dataChanged(), initStyleOptionForIndex(), QTableWidgetPrivate::sort(), and QTreeWidgetPrivate::sort().

+ Here is the caller graph for this function:

◆ sortIndicatorSection()

int QHeaderView::sortIndicatorSection ( ) const

Returns the logical index of the section that has a sort indicator.

By default this is section 0.

See also
setSortIndicator(), sortIndicatorOrder(), setSortIndicatorShown()

Definition at line 1379 of file qheaderview.cpp.

References d.

Referenced by QTableWidgetPrivate::dataChanged(), QTreeWidgetPrivate::dataChanged(), initStyleOptionForIndex(), setSortIndicatorShown(), QTableWidgetPrivate::sort(), QTreeWidgetPrivate::sort(), and QTreeWidget::sortColumn().

+ Here is the caller graph for this function:

◆ stretchLastSection()

bool QHeaderView::stretchLastSection ( ) const

Definition at line 1448 of file qheaderview.cpp.

References d.

◆ stretchSectionCount()

int QHeaderView::stretchSectionCount ( ) const
Since
4.1

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's geometry changes.

See also
stretchLastSection

Definition at line 1291 of file qheaderview.cpp.

References d.

◆ swapSections()

void QHeaderView::swapSections ( int first,
int second )
Since
4.2 Swaps the section at visual index first with the section at visual index second.
See also
moveSection()

Definition at line 761 of file qheaderview.cpp.

References d, emit, QHeaderViewPrivate::ResizeSection, sectionMoved(), stretchLastSection, and visualIndex().

+ Here is the call graph for this function:

◆ updateGeometries()

void QHeaderView::updateGeometries ( )
overrideprotectedvirtual

\reimp

Reimplemented from QAbstractItemView.

Definition at line 3059 of file qheaderview.cpp.

References d.

◆ updateSection

void QHeaderView::updateSection ( int logicalIndex)
protectedslot
Since
4.2

Updates the section specified by the given logicalIndex.

Definition at line 1811 of file qheaderview.cpp.

References d, Qt::Horizontal, logicalIndex(), sectionSize(), and sectionViewportPosition().

Referenced by event(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), moveSection(), and setSortIndicator().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ verticalOffset()

int QHeaderView::verticalOffset ( ) const
overrideprotectedvirtual

Returns the vertical offset of the header.

This is 0 for horizontal headers.

See also
offset()

Implements QAbstractItemView.

Definition at line 3046 of file qheaderview.cpp.

References d, and Qt::Vertical.

◆ viewportEvent()

◆ visualIndex()

int QHeaderView::visualIndex ( int logicalIndex) const

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()

Definition at line 1024 of file qheaderview.cpp.

References d, logicalIndex(), and Q_ASSERT.

Referenced by QTreeViewPrivate::adjustViewOptionsForIndex(), QTreeViewPrivate::columnRanges(), QTableViewPrivate::drawAndClipSpans(), QTreeView::drawRow(), headerDataChanged(), initStyleOptionForIndex(), isSectionHidden(), logicalIndex(), mouseMoveEvent(), mouseReleaseEvent(), moveSection(), resizeSection(), sectionPosition(), sectionResizeMode(), sectionSize(), setSectionHidden(), setSectionResizeMode(), swapSections(), QTableWidget::visualColumn(), visualRegionForSelection(), and QTableWidget::visualRow().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ visualIndexAt()

int QHeaderView::visualIndexAt ( int position) const

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

See also
logicalIndexAt()

Definition at line 551 of file qheaderview.cpp.

References d, and position().

Referenced by logicalIndexAt(), mouseMoveEvent(), paintEvent(), QTableView::paintEvent(), and QTreeViewPrivate::startAndEndColumns().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ visualRect()

QRect QHeaderView::visualRect ( const QModelIndex & index) const
overrideprotectedvirtual

\reimp

Empty implementation because the header doesn't show QModelIndex items.

Implements QAbstractItemView.

Definition at line 3132 of file qheaderview.cpp.

◆ visualRegionForSelection()

QRegion QHeaderView::visualRegionForSelection ( const QItemSelection & selection) const
overrideprotectedvirtual

Implements QAbstractItemView.

Definition at line 3203 of file qheaderview.cpp.

References count(), d, Qt::Horizontal, logicalIndex(), sectionSize(), sectionViewportPosition(), selection, and visualIndex().

+ Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ QTableView

friend class QTableView
friend

Definition at line 210 of file qheaderview.h.

◆ QTreeView

friend class QTreeView
friend

Definition at line 211 of file qheaderview.h.

Property Documentation

◆ cascadingSectionResizes

QHeaderView::cascadingSectionResizes
readwrite

whether interactive resizing will be cascaded to the following sections once the section being resized by the user has reached its minimum size

Since
4.2

This property only affects sections that have \l Interactive as their resize mode.

The default value is false.

See also
setSectionResizeMode()

Definition at line 26 of file qheaderview.h.

◆ defaultAlignment

QHeaderView::defaultAlignment
readwrite

the default alignment of the text in each header section

Since
4.1

Definition at line 32 of file qheaderview.h.

◆ defaultSectionSize

QHeaderView::defaultSectionSize
readwrite

the default size of the header sections before resizing.

This property only affects sections that have \l Interactive or \l Fixed as their resize mode.

By default, the value of this property is style dependent. Thus, when the style changes, this property updates from it. Calling setDefaultSectionSize() stops the updates, calling resetDefaultSectionSize() will restore default behavior.

See also
setSectionResizeMode(), minimumSectionSize

Definition at line 28 of file qheaderview.h.

◆ firstSectionMovable

QHeaderView::firstSectionMovable
readwrite

Whether the first column can be moved by the user.

This property controls whether the first column can be moved by the user. In a QTreeView, the first column holds the tree structure and is therefore non-movable by default, even after setSectionsMovable(true).

It can be made movable again, for instance in the case of flat lists without a tree structure, by calling this method. In such a scenario, it is recommended to call QTreeView::setRootIsDecorated(false) as well.

treeView->setRootIsDecorated(false);
treeView->header()->setFirstSectionMovable(true);

Setting it to true has no effect unless setSectionsMovable(true) is called as well.

See also
setSectionsMovable()
Since
5.11

Definition at line 20 of file qheaderview.h.

◆ highlightSections

QHeaderView::highlightSections
readwrite

whether the sections containing selected items are highlighted

By default, this property is false.

Definition at line 24 of file qheaderview.h.

◆ maximumSectionSize

QHeaderView::maximumSectionSize
readwrite

the maximum size of the header sections.

Since
5.2

The maximum section size is the largest section size allowed. The default value for this property is 1048575, which is also the largest possible size for a section. Setting maximum to -1 will reset the value to the largest section size.

With exception of stretch this property is honored by all \l{ResizeMode}{resize modes}

See also
setSectionResizeMode(), defaultSectionSize

Definition at line 31 of file qheaderview.h.

Referenced by mouseMoveEvent(), resizeSection(), sectionSizeHint(), and setMinimumSectionSize().

◆ minimumSectionSize

QHeaderView::minimumSectionSize
readwrite

the minimum size of the header sections.

Since
4.2

The minimum section size is the smallest section size allowed. If the minimum section size is set to -1, QHeaderView will use the \l{fontMetrics()}{font metrics} size.

This property is honored by all \l{ResizeMode}{resize modes}.

See also
setSectionResizeMode(), defaultSectionSize

Definition at line 30 of file qheaderview.h.

Referenced by mouseMoveEvent(), resizeSection(), sectionSizeHint(), and setMaximumSectionSize().

◆ sectionsClickable

QHeaderView::sectionsClickable
readwrite

Holds true if the header is clickable; otherwise 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
sectionPressed(), setSortIndicatorShown()

Definition at line 23 of file qheaderview.h.

◆ sectionsMovable

QHeaderView::sectionsMovable
readwrite

If sectionsMovable is true, the header sections may be moved by the user; otherwise they are fixed in place.

When used in combination with QTreeView, the first column is not movable (since it contains the tree structure), by default. You can make it movable with setFirstSectionMovable(true).

See also
sectionMoved()
setFirstSectionMovable()

Definition at line 22 of file qheaderview.h.

◆ showSortIndicator

QHeaderView::showSortIndicator
readwrite

whether the sort indicator is shown

By default, this property is false.

See also
setSectionsClickable()

Definition at line 21 of file qheaderview.h.

◆ sortIndicatorClearable

QHeaderView::sortIndicatorClearable
readwrite

Whether the sort indicator can be cleared by clicking on a section multiple times.

Since
6.1

This property controls whether the user is able to remove the sorting indicator on a given section by clicking on the section multiple times. Normally, clicking on a section will simply change the sorting order for that section. By setting this property to true, the sorting indicator will be cleared after alternating to ascending and descending; this will typically restore the original sorting of a model.

Setting this property to true has no effect unless sectionsClickable() is also true (which is the default for certain views, for instance QTableView, or is automatically set when making a view sortable, for instance by calling QTreeView::setSortingEnabled).

Definition at line 33 of file qheaderview.h.

◆ stretchLastSection

QHeaderView::stretchLastSection
readwrite

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
setSectionResizeMode()

Definition at line 25 of file qheaderview.h.

Referenced by initializeSections(), moveSection(), resizeSection(), sectionsInserted(), setSectionHidden(), and swapSections().


The documentation for this class was generated from the following files: