Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
The QHeaderView class provides a header row or header column for item views. More...
#include <qheaderview.h>
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 } |
Describes how the scrollbar should behave. More... | |
Public Slots | |
void | setOffset (int offset) |
Sets the header's offset to offset. | |
void | setOffsetToSectionPosition (int visualIndex) |
Sets the offset to the start of the section at the given visualSectionNumber. | |
void | setOffsetToLastSection () |
Sets the offset to make the last section visible. | |
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 () |
Scrolls the view to the top. | |
void | scrollToBottom () |
Scrolls the view to the bottom. | |
void | update (const QModelIndex &index) |
Updates the area occupied by the given 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) |
This signal is emitted when the cursor moves over the section and the left mouse button is pressed. | |
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 () |
This signal is emitted when the header's geometries have changed. | |
void | sortIndicatorChanged (int logicalIndex, Qt::SortOrder order) |
This signal is emitted when the section containing the sort indicator or the order indicated is changed. | |
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) |
Swaps the section at visual index first with the section at visual index 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 |
Returns the number of sections in the header that has been hidden. | |
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 |
Returns the number of sections that are set to resize mode stretch. | |
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 |
Returns true if sections in the header has been hidden; otherwise returns false;. | |
QByteArray | saveState () const |
Saves the current state of this header view. | |
bool | restoreState (const QByteArray &state) |
Restores the state of this header view. | |
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. | |
QAbstractItemModel * | model () const |
Returns the model that this view is presenting. | |
virtual void | setSelectionModel (QItemSelectionModel *selectionModel) |
Sets the current selection model to the given selectionModel. | |
QItemSelectionModel * | selectionModel () const |
Returns the current selection model. | |
void | setItemDelegate (QAbstractItemDelegate *delegate) |
Sets the item delegate for this view and its model to delegate. | |
QAbstractItemDelegate * | itemDelegate () 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. | |
uint32_t | updateThreshold () const |
void | setUpdateThreshold (uint32_t threshold) |
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) |
Sets the given widget on the item at the given index, passing the ownership of the widget to the viewport. | |
QWidget * | indexWidget (const QModelIndex &index) const |
Returns the widget for the item at the given index. | |
void | setItemDelegateForRow (int row, QAbstractItemDelegate *delegate) |
Sets the given item delegate used by this view and model for the given row. | |
QAbstractItemDelegate * | itemDelegateForRow (int row) const |
Returns the item delegate used by this view and model for the given row, or \nullptr if no delegate has been assigned. | |
void | setItemDelegateForColumn (int column, QAbstractItemDelegate *delegate) |
Sets the given item delegate used by this view and model for the given column. | |
QAbstractItemDelegate * | itemDelegateForColumn (int column) const |
Returns the item delegate used by this view and model for the given column. | |
virtual QAbstractItemDelegate * | itemDelegateForIndex (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 ¤t, 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 ®ion) |
Marks the given region as dirty and schedules it to be updated. | |
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 | |
uint32_t | updateThreshold |
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... | |
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.
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.
Enumerator | |
---|---|
Interactive | |
Stretch | |
Fixed | |
ResizeToContents | |
Custom |
Definition at line 38 of file qheaderview.h.
|
explicit |
Creates a new generic header with the given orientation and parent.
Definition at line 284 of file qheaderview.cpp.
|
virtual |
Destroys the header.
Definition at line 308 of file qheaderview.cpp.
|
protected |
Definition at line 295 of file qheaderview.cpp.
bool QHeaderView::cascadingSectionResizes | ( | ) | const |
Definition at line 1522 of file qheaderview.cpp.
int QHeaderView::count | ( | ) | const |
Returns the number of sections in the header.
Definition at line 1033 of file qheaderview.cpp.
|
overrideprotectedvirtual |
|
overrideprotectedvirtual |
Qt::Alignment QHeaderView::defaultAlignment | ( | ) | const |
Definition at line 1682 of file qheaderview.cpp.
int QHeaderView::defaultSectionSize | ( | ) | const |
Definition at line 1548 of file qheaderview.cpp.
|
overridevirtual |
Reimplemented from QAbstractItemView.
Definition at line 1701 of file qheaderview.cpp.
|
overrideprotected |
\reimp
Definition at line 2452 of file qheaderview.cpp.
|
signal |
This signal is emitted when the header's geometries have changed.
|
slot |
Updates the changed header sections with the given orientation, from logicalFirst to logicalLast inclusive.
Definition at line 1849 of file qheaderview.cpp.
int QHeaderView::hiddenSectionCount | ( | ) | const |
Returns the number of sections in the header that has been hidden.
Definition at line 973 of file qheaderview.cpp.
|
inline |
Hides the section specified by logicalIndex.
Definition at line 224 of file qheaderview.h.
bool QHeaderView::highlightSections | ( | ) | const |
Definition at line 1197 of file qheaderview.cpp.
|
overrideprotectedvirtual |
Returns the horizontal offset of the header.
This is 0 for vertical headers.
Implements QAbstractItemView.
Definition at line 3143 of file qheaderview.cpp.
|
overrideprotectedvirtual |
\reimp
Empty implementation because the header doesn't show QModelIndex items.
Implements QAbstractItemView.
Definition at line 3268 of file qheaderview.cpp.
|
protected |
Definition at line 317 of file qheaderview.cpp.
|
protected |
Definition at line 2320 of file qheaderview.cpp.
|
protected |
Definition at line 2354 of file qheaderview.cpp.
|
overrideprivate |
Definition at line 3529 of file qheaderview.cpp.
|
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.
Definition at line 3516 of file qheaderview.cpp.
|
protectedvirtual |
Initializes the style option from the specified logicalIndex. This function is called by the default implementation of paintSection after initStyleOption has been called.
Definition at line 2961 of file qheaderview.cpp.
bool QHeaderView::isFirstSectionMovable | ( | ) | const |
Definition at line 1158 of file qheaderview.cpp.
|
overrideprotectedvirtual |
\reimp
Empty implementation because the header doesn't show QModelIndex items.
Implements QAbstractItemView.
Definition at line 3280 of file qheaderview.cpp.
bool QHeaderView::isSectionHidden | ( | int | logicalIndex | ) | const |
Returns true
if the section specified by logicalIndex is explicitly hidden from the user; otherwise returns false
.
Definition at line 953 of file qheaderview.cpp.
bool QHeaderView::isSortIndicatorClearable | ( | ) | const |
Definition at line 1463 of file qheaderview.cpp.
bool QHeaderView::isSortIndicatorShown | ( | ) | const |
Definition at line 1359 of file qheaderview.cpp.
int QHeaderView::length | ( | ) | const |
Returns the length along the orientation of the header.
Definition at line 470 of file qheaderview.cpp.
Referenced by testing.tools.encode_pdf_filter._PngIdatPdfStream::write().
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.
Definition at line 1084 of file qheaderview.cpp.
|
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.
Definition at line 222 of file qheaderview.h.
int QHeaderView::logicalIndexAt | ( | int | position | ) | const |
Returns the section that covers the given position in the viewport.
Definition at line 599 of file qheaderview.cpp.
|
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.
int QHeaderView::maximumSectionSize | ( | ) | const |
Definition at line 1638 of file qheaderview.cpp.
int QHeaderView::minimumSectionSize | ( | ) | const |
Definition at line 1586 of file qheaderview.cpp.
|
overrideprotected |
\reimp
Definition at line 2846 of file qheaderview.cpp.
|
overrideprotected |
\reimp
Definition at line 2655 of file qheaderview.cpp.
|
overrideprotected |
\reimp
Definition at line 2610 of file qheaderview.cpp.
|
overrideprotected |
\reimp
Definition at line 2773 of file qheaderview.cpp.
|
overrideprotectedvirtual |
\reimp
Empty implementation because the header doesn't show QModelIndex items.
Implements QAbstractItemView.
Definition at line 3292 of file qheaderview.cpp.
void QHeaderView::moveSection | ( | int | from, |
int | to ) |
Moves the section at visual index from to occupy visual index to.
Definition at line 713 of file qheaderview.cpp.
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.
Definition at line 399 of file qheaderview.cpp.
Referenced by testing.tools.fixup_pdf_template.TemplateProcessor::insert_xref_entry(), and testing.tools.fixup_pdf_template.TemplateProcessor::process_line().
Qt::Orientation QHeaderView::orientation | ( | ) | const |
Returns the orientation of the header.
Definition at line 386 of file qheaderview.cpp.
|
overrideprotected |
\reimp
Definition at line 2504 of file qheaderview.cpp.
|
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 3063 of file qheaderview.cpp.
|
overridevirtual |
void QHeaderView::resetDefaultSectionSize | ( | ) |
Definition at line 1563 of file qheaderview.cpp.
int QHeaderView::resizeContentsPrecision | ( | ) | const |
Definition at line 1313 of file qheaderview.cpp.
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.
Definition at line 841 of file qheaderview.cpp.
|
protectedslot |
Resizes the sections according to their size hints.
Normally, you do not have to call this function.
Definition at line 1902 of file qheaderview.cpp.
void QHeaderView::resizeSections | ( | QHeaderView::ResizeMode | mode | ) |
Resizes the sections according to the given mode, ignoring the current resize mode.
Definition at line 924 of file qheaderview.cpp.
bool QHeaderView::restoreState | ( | const QByteArray & | state | ) |
Restores the state of this header view.
This function returns true
if the state was restored; otherwise returns false.
Definition at line 1800 of file qheaderview.cpp.
|
overrideprotectedvirtual |
\reimp
Empty implementation because the header doesn't show QModelIndex items.
Reimplemented from QAbstractItemView.
Definition at line 3232 of file qheaderview.cpp.
QByteArray QHeaderView::saveState | ( | ) | const |
Saves the current state of this header view.
To restore the saved state, pass the return value to restoreState().
Definition at line 1781 of file qheaderview.cpp.
|
overrideprotected |
\reimp
Definition at line 3184 of file qheaderview.cpp.
|
overrideprotectedvirtual |
\reimp
Empty implementation because the header doesn't show QModelIndex items.
Implements QAbstractItemView.
Definition at line 3256 of file qheaderview.cpp.
|
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.
|
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.
|
signal |
This signal is emitted when a section is double-clicked.
The section's logical index is specified by logicalIndex.
|
signal |
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.
|
signal |
This signal is emitted when a section is double-clicked.
The section's logical index is specified by logicalIndex.
|
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.
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.
Definition at line 639 of file qheaderview.cpp.
|
signal |
This signal is emitted when a section is pressed.
The section's logical index is specified by logicalIndex.
|
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.
QHeaderView::ResizeMode QHeaderView::sectionResizeMode | ( | int | logicalIndex | ) | const |
Returns the resize mode that applies to the section specified by the given logicalIndex.
Definition at line 1268 of file qheaderview.cpp.
|
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 2029 of file qheaderview.cpp.
bool QHeaderView::sectionsClickable | ( | ) | const |
Returns \l sectionsClickable.
Definition at line 1185 of file qheaderview.cpp.
bool QHeaderView::sectionsHidden | ( | ) | const |
Returns true
if sections in the header has been hidden; otherwise returns false;.
Definition at line 1725 of file qheaderview.cpp.
|
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 1918 of file qheaderview.cpp.
int QHeaderView::sectionSize | ( | int | logicalIndex | ) | const |
Returns the width (or height for vertical headers) of the given logicalIndex.
Definition at line 614 of file qheaderview.cpp.
|
protectedvirtual |
Returns the size of the contents of the section specified by the given logicalIndex.
Definition at line 3100 of file qheaderview.cpp.
int QHeaderView::sectionSizeHint | ( | int | logicalIndex | ) | const |
Returns a suitable size hint for the section specified by logicalIndex.
Definition at line 537 of file qheaderview.cpp.
bool QHeaderView::sectionsMovable | ( | ) | const |
Returns \l sectionsMovable.
Definition at line 1122 of file qheaderview.cpp.
bool QHeaderView::sectionsMoved | ( | ) | const |
Returns true
if sections in the header has been moved; otherwise returns false;.
Definition at line 1713 of file qheaderview.cpp.
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.
Definition at line 659 of file qheaderview.cpp.
void QHeaderView::setCascadingSectionResizes | ( | bool | enable | ) |
Definition at line 1528 of file qheaderview.cpp.
void QHeaderView::setDefaultAlignment | ( | Qt::Alignment | alignment | ) |
Definition at line 1688 of file qheaderview.cpp.
void QHeaderView::setDefaultSectionSize | ( | int | size | ) |
Definition at line 1554 of file qheaderview.cpp.
void QHeaderView::setFirstSectionMovable | ( | bool | movable | ) |
Definition at line 1152 of file qheaderview.cpp.
void QHeaderView::setHighlightSections | ( | bool | highlight | ) |
Definition at line 1191 of file qheaderview.cpp.
void QHeaderView::setMaximumSectionSize | ( | int | size | ) |
Definition at line 1646 of file qheaderview.cpp.
void QHeaderView::setMinimumSectionSize | ( | int | size | ) |
Definition at line 1598 of file qheaderview.cpp.
|
overridevirtual |
|
slot |
Sets the header's offset to offset.
Definition at line 413 of file qheaderview.cpp.
|
slot |
Sets the offset to make the last section visible.
Definition at line 456 of file qheaderview.cpp.
|
slot |
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().
Definition at line 442 of file qheaderview.cpp.
void QHeaderView::setResizeContentsPrecision | ( | int | precision | ) |
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.
Definition at line 1299 of file qheaderview.cpp.
void QHeaderView::setSectionHidden | ( | int | logicalIndex, |
bool | hide ) |
If hide is true the section specified by logicalIndex is hidden; otherwise the section is shown.
Definition at line 986 of file qheaderview.cpp.
void QHeaderView::setSectionResizeMode | ( | int | logicalIndex, |
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. The logical index should exist at the time this function is called.
Definition at line 1237 of file qheaderview.cpp.
void QHeaderView::setSectionResizeMode | ( | ResizeMode | mode | ) |
Sets the constraints on how the header can be resized to those described by the given mode.
Definition at line 1212 of file qheaderview.cpp.
void QHeaderView::setSectionsClickable | ( | bool | clickable | ) |
Set \l sectionsClickable to clickable.
Definition at line 1176 of file qheaderview.cpp.
void QHeaderView::setSectionsMovable | ( | bool | movable | ) |
Sets \l sectionsMovable to movable.
Definition at line 1113 of file qheaderview.cpp.
|
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 3306 of file qheaderview.cpp.
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.
Definition at line 1377 of file qheaderview.cpp.
void QHeaderView::setSortIndicatorClearable | ( | bool | clearable | ) |
Definition at line 1454 of file qheaderview.cpp.
void QHeaderView::setSortIndicatorShown | ( | bool | show | ) |
Definition at line 1342 of file qheaderview.cpp.
void QHeaderView::setStretchLastSection | ( | bool | stretch | ) |
Definition at line 1490 of file qheaderview.cpp.
|
override |
\reimp
Definition at line 518 of file qheaderview.cpp.
|
inline |
Shows the section specified by logicalIndex.
Definition at line 226 of file qheaderview.h.
|
override |
Returns a suitable size hint for this header.
Definition at line 485 of file qheaderview.cpp.
|
signal |
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.
|
signal |
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.
Definition at line 1428 of file qheaderview.cpp.
int QHeaderView::sortIndicatorSection | ( | ) | const |
Returns the logical index of the section that has a sort indicator.
By default this is section 0.
Definition at line 1415 of file qheaderview.cpp.
bool QHeaderView::stretchLastSection | ( | ) | const |
Definition at line 1484 of file qheaderview.cpp.
int QHeaderView::stretchSectionCount | ( | ) | const |
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.
Definition at line 1327 of file qheaderview.cpp.
void QHeaderView::swapSections | ( | int | first, |
int | second ) |
Swaps the section at visual index first with the section at visual index second.
Definition at line 777 of file qheaderview.cpp.
|
overrideprotectedvirtual |
|
protectedslot |
Updates the section specified by the given logicalIndex.
Definition at line 1886 of file qheaderview.cpp.
|
overrideprotectedvirtual |
Returns the vertical offset of the header.
This is 0 for horizontal headers.
Implements QAbstractItemView.
Definition at line 3158 of file qheaderview.cpp.
|
overrideprotected |
\reimp
Definition at line 2872 of file qheaderview.cpp.
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.
Definition at line 1051 of file qheaderview.cpp.
int QHeaderView::visualIndexAt | ( | int | position | ) | const |
Returns the visual index of the section that covers the given position in the viewport.
Definition at line 561 of file qheaderview.cpp.
|
overrideprotectedvirtual |
\reimp
Empty implementation because the header doesn't show QModelIndex items.
Implements QAbstractItemView.
Definition at line 3244 of file qheaderview.cpp.
|
overrideprotectedvirtual |
Implements QAbstractItemView.
Definition at line 3315 of file qheaderview.cpp.
|
friend |
Definition at line 210 of file qheaderview.h.
|
friend |
Definition at line 211 of file qheaderview.h.
|
readwrite |
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 \l Interactive as their resize mode.
The default value is false.
Definition at line 26 of file qheaderview.h.
|
readwrite |
the default alignment of the text in each header section
Definition at line 32 of file qheaderview.h.
|
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.
Definition at line 28 of file qheaderview.h.
|
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.
Setting it to true has no effect unless setSectionsMovable(true) is called as well.
Definition at line 20 of file qheaderview.h.
|
readwrite |
whether the sections containing selected items are highlighted
By default, this property is false
.
Definition at line 24 of file qheaderview.h.
|
readwrite |
the maximum size of the header sections.
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}
Definition at line 31 of file qheaderview.h.
|
readwrite |
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 \l{fontMetrics()}{font metrics} size.
This property is honored by all \l{ResizeMode}{resize modes}.
Definition at line 30 of file qheaderview.h.
|
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.
Definition at line 23 of file qheaderview.h.
|
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).
Definition at line 22 of file qheaderview.h.
|
readwrite |
whether the sort indicator is shown
By default, this property is false
.
Definition at line 21 of file qheaderview.h.
|
readwrite |
Whether the sort indicator can be cleared by clicking on a section multiple times.
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.
|
readwrite |
whether the last visible section in the header takes up all the available space
The default value is false.
Definition at line 25 of file qheaderview.h.