![]() |
Qt 6.x
The Qt SDK
|
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... | |
![]() | |
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. | |
![]() | |
virtual void | reset () |
Reset the internal state of the view. | |
virtual void | setRootIndex (const QModelIndex &index) |
Sets the root item to the item at the given index. | |
virtual void | doItemsLayout () |
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) |
![]() | |
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) |
bool | sectionsMovable () const |
void | setFirstSectionMovable (bool movable) |
bool | isFirstSectionMovable () const |
void | setSectionsClickable (bool clickable) |
bool | sectionsClickable () const |
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 | |
![]() | |
QAbstractItemView (QWidget *parent=nullptr) | |
Constructs an abstract item view with the given parent. | |
~QAbstractItemView () | |
Destroys the view. | |
virtual void | setModel (QAbstractItemModel *model) |
Sets the model for the view to present. | |
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. | |
virtual QRect | visualRect (const QModelIndex &index) const =0 |
Returns the rectangle on the viewport occupied by the item at index. | |
virtual void | scrollTo (const QModelIndex &index, ScrollHint hint=EnsureVisible)=0 |
Scrolls the view if necessary to ensure that the item at index is visible. | |
virtual QModelIndex | indexAt (const QPoint &point) const =0 |
Returns the model index of the item at the viewport coordinates point. | |
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) |
QWidget * | indexWidget (const QModelIndex &index) const |
void | setItemDelegateForRow (int row, QAbstractItemDelegate *delegate) |
QAbstractItemDelegate * | itemDelegateForRow (int row) const |
void | setItemDelegateForColumn (int column, QAbstractItemDelegate *delegate) |
QAbstractItemDelegate * | itemDelegateForColumn (int column) const |
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. | |
![]() | |
virtual void | dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList< int > &roles=QList< int >()) |
This slot is called when items with the given roles are changed in the model. | |
virtual void | rowsInserted (const QModelIndex &parent, int start, int end) |
This slot is called when rows are inserted. | |
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 | currentChanged (const QModelIndex ¤t, const QModelIndex &previous) |
This slot is called when a new item becomes the current item. | |
virtual void | updateEditorData () |
virtual void | updateEditorGeometries () |
virtual void | updateGeometries () |
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. | |
![]() | |
QAbstractItemView (QAbstractItemViewPrivate &, QWidget *parent=nullptr) | |
virtual QModelIndex | moveCursor (CursorAction cursorAction, Qt::KeyboardModifiers modifiers)=0 |
Returns a QModelIndex object pointing to the next object in the view, based on the given cursorAction and keyboard modifiers specified by modifiers. | |
virtual int | horizontalOffset () const =0 |
Returns the horizontal offset of the view. | |
virtual int | verticalOffset () const =0 |
Returns the vertical offset of the view. | |
virtual bool | isIndexHidden (const QModelIndex &index) const =0 |
Returns true if the item referred to by the given index is hidden in the view, otherwise returns false . | |
virtual void | setSelection (const QRect &rect, QItemSelectionModel::SelectionFlags command)=0 |
Applies the selection flags to the items in or touched by the rectangle, rect. | |
virtual QRegion | visualRegionForSelection (const QItemSelection &selection) const =0 |
Returns the region from the viewport of the items in the given selection. | |
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) |
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 | 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. | |
![]() | |
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 | |
![]() | |
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 36 of file qheaderview.h.
|
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().
|
virtual |
Destroys the header.
Definition at line 296 of file qheaderview.cpp.
|
protected |
Definition at line 283 of file qheaderview.cpp.
References d, initialize(), and orientation().
bool QHeaderView::cascadingSectionResizes | ( | ) | const |
Definition at line 1525 of file qheaderview.cpp.
References d.
int QHeaderView::count | ( | ) | const |
Returns the number of sections in the header.
Definition at line 1037 of file qheaderview.cpp.
References d.
Referenced by QTreeViewPrivate::adjustViewOptionsForIndex(), QTreeViewPrivate::calcLogicalIndices(), QTreeView::drawRow(), headerDataChanged(), QTreeView::moveCursor(), paintEvent(), QTableView::paintEvent(), resizeSection(), sectionsInserted(), sectionSize(), sectionSizeHint(), sectionViewportPosition(), setSectionHidden(), setSectionResizeMode(), setSortIndicatorShown(), sizeHint(), QTreeViewPrivate::startAndEndColumns(), QTreeViewPrivate::updateScrollBars(), and visualRegionForSelection().
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractItemView.
Definition at line 2355 of file qheaderview.cpp.
References QModelIndex::column(), d, Qt::Horizontal, QModelIndex::isValid(), QModelIndex::parent(), QModelIndex::row(), sectionSize(), sectionViewportPosition(), and Qt::Vertical.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractItemView.
Definition at line 3119 of file qheaderview.cpp.
References QList< T >::begin(), QModelIndex::column(), d, Qt::DecorationRole, Qt::DisplayRole, QList< T >::end(), Qt::FontRole, Qt::Horizontal, i, QList< T >::isEmpty(), orientation(), ResizeToContents, QModelIndex::row(), sectionResizeMode(), Qt::SizeHintRole, and Qt::UserRole.
Qt::Alignment QHeaderView::defaultAlignment | ( | ) | const |
Definition at line 1684 of file qheaderview.cpp.
References d.
int QHeaderView::defaultSectionSize | ( | ) | const |
Definition at line 1551 of file qheaderview.cpp.
References d.
|
overridevirtual |
Reimplemented from QAbstractItemView.
Definition at line 1703 of file qheaderview.cpp.
References QAbstractItemView::doItemsLayout(), and initializeSections().
|
overrideprotected |
\reimp
Definition at line 2381 of file qheaderview.cpp.
References d, e, QAbstractItemView::event(), QEvent::HoverEnter, QEvent::HoverLeave, QEvent::HoverMove, QEvent::Leave, logicalIndexAt(), QSinglePointEvent::position(), resizeSections(), QEvent::StyleChange, QEvent::Timer, QTimerEvent::timerId(), QPointF::toPoint(), and updateSection().
|
signal |
This signal is emitted when the header's geometries have changed.
Referenced by viewportEvent().
|
slot |
Updates the changed header sections with the given orientation, from logicalFirst to logicalLast inclusive.
Definition at line 1814 of file qheaderview.cpp.
References count(), d, Qt::Horizontal, orientation(), qMax(), qMin(), and visualIndex().
Referenced by setModel().
int QHeaderView::hiddenSectionCount | ( | ) | const |
Returns the number of sections in the header that has been hidden.
Definition at line 980 of file qheaderview.cpp.
References d.
|
inline |
Hides the section specified by logicalIndex.
Definition at line 230 of file qheaderview.h.
References setSectionHidden().
bool QHeaderView::highlightSections | ( | ) | const |
Definition at line 1200 of file qheaderview.cpp.
References d.
|
overrideprotectedvirtual |
Returns the horizontal offset of the header.
This is 0 for vertical headers.
Implements QAbstractItemView.
Definition at line 3068 of file qheaderview.cpp.
References d, and Qt::Horizontal.
|
overrideprotectedvirtual |
\reimp
Empty implementation because the header doesn't show QModelIndex items.
Implements QAbstractItemView.
Definition at line 3193 of file qheaderview.cpp.
|
protected |
Definition at line 303 of file qheaderview.cpp.
References QPalette::Button, d, Qt::ElideNone, Qt::NoFocus, Qt::ScrollBarAlwaysOff, and setFrameStyle().
Referenced by QHeaderView(), and QHeaderView().
|
protected |
Definition at line 2258 of file qheaderview.cpp.
References d, emit, initializeSections(), qBound(), sectionCountChanged(), and stretchLastSection.
Referenced by doItemsLayout(), initializeSections(), reset(), setModel(), and setSectionResizeMode().
|
protected |
Definition at line 2283 of file qheaderview.cpp.
References d, emit, i, it, j, Q_ASSERT, ResizeToContents, sectionCountChanged(), and Stretch.
|
overrideprivate |
Definition at line 3454 of file qheaderview.cpp.
References QFrame::initStyleOption().
|
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 3441 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().
|
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 2886 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(), QStyleOptionHeaderV2::isSectionDragTarget, 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, QStyleOptionHeaderV2::textElideMode, var, variant, visualIndex(), QPalette::Window, and window().
Referenced by paintSection().
bool QHeaderView::isFirstSectionMovable | ( | ) | const |
Definition at line 1157 of file qheaderview.cpp.
References d.
|
overrideprotectedvirtual |
\reimp
Empty implementation because the header doesn't show QModelIndex items.
Implements QAbstractItemView.
Definition at line 3205 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 962 of file qheaderview.cpp.
References d, logicalIndex(), Q_ASSERT, and visualIndex().
Referenced by QTreeViewPrivate::calcLogicalIndices(), QTreeViewPrivate::columnRanges(), QTableViewPrivate::isColumnHidden(), QTableViewPrivate::isRowHidden(), QTableView::paintEvent(), resizeSection(), QFileDialogPrivate::restoreWidgetState(), sectionSize(), sectionSizeHint(), sizeHint(), and QTableViewPrivate::trimHiddenSelections().
bool QHeaderView::isSortIndicatorClearable | ( | ) | const |
Definition at line 1468 of file qheaderview.cpp.
References d.
bool QHeaderView::isSortIndicatorShown | ( | ) | const |
Definition at line 1364 of file qheaderview.cpp.
References d.
Referenced by initStyleOptionForIndex(), and sectionSizeFromContents().
int QHeaderView::length | ( | ) | const |
Returns the length along the orientation of the header.
Definition at line 491 of file qheaderview.cpp.
References d.
Referenced by QTreeView::drawRow(), QTableView::paintEvent(), setOffsetToLastSection(), and QTreeViewPrivate::updateScrollBars().
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 1081 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().
|
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 228 of file qheaderview.h.
References logicalIndexAt(), QPoint::x(), and QPoint::y().
int QHeaderView::logicalIndexAt | ( | int | position | ) | const |
Returns the section that covers the given position in the viewport.
Definition at line 616 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().
|
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 226 of file qheaderview.h.
References Qt::Horizontal, logicalIndexAt(), and orientation().
int QHeaderView::maximumSectionSize | ( | ) | const |
Definition at line 1639 of file qheaderview.cpp.
References d, and maxSizeSection.
int QHeaderView::minimumSectionSize | ( | ) | const |
Definition at line 1587 of file qheaderview.cpp.
References d, fontMetrics, Qt::Horizontal, and QStyle::PM_HeaderMargin.
|
overrideprotected |
\reimp
Definition at line 2771 of file qheaderview.cpp.
References Qt::ArrowCursor, cursor, d, e, emit, Qt::Horizontal, Interactive, logicalIndexAt(), pos, sectionDoubleClicked(), sectionHandleDoubleClicked(), sectionResizeMode(), setCursor(), Qt::SplitHCursor, and Qt::SplitVCursor.
|
overrideprotected |
\reimp
Definition at line 2580 of file qheaderview.cpp.
References d, e, emit, Qt::Horizontal, Interactive, QString::isEmpty(), logicalIndex(), logicalIndexAt(), maximumSectionSize, minimumSectionSize, QHeaderViewPrivate::MoveSection, Qt::NoButton, QHeaderViewPrivate::NoState, pos, Q_ASSERT, qAbs(), qBound(), qMax(), QT_CONFIG, resizeSection(), QHeaderViewPrivate::ResizeSection, sectionEntered(), sectionResizeMode(), QHeaderViewPrivate::SelectSections, QCoreApplication::sendEvent(), setCursor(), Qt::SplitHCursor, Qt::SplitVCursor, QApplication::startDragDistance, QAbstractItemView::state(), Qt::StatusTipRole, unsetCursor(), updateSection(), visualIndex(), visualIndexAt(), and Qt::WA_SetCursor.
|
overrideprotected |
\reimp
Definition at line 2535 of file qheaderview.cpp.
References d, e, emit, Qt::Horizontal, Interactive, Qt::LeftButton, logicalIndexAt(), QHeaderViewPrivate::MoveSection, QHeaderViewPrivate::NoState, pos, QHeaderViewPrivate::ResizeSection, sectionPressed(), sectionResizeMode(), sectionSize(), QHeaderViewPrivate::SelectSections, and updateSection().
|
overrideprotected |
\reimp
Definition at line 2698 of file qheaderview.cpp.
References QRect::contains(), d, e, emit, Qt::Horizontal, logicalIndexAt(), moveSection(), QHeaderViewPrivate::MoveSection, QHeaderViewPrivate::NoState, pos, Q_ASSERT, Q_FALLTHROUGH, QT_CONFIG, QHeaderViewPrivate::ResizeSection, sectionClicked(), sectionSize(), sectionViewportPosition(), QHeaderViewPrivate::SelectSections, QRect::setRect(), updateSection(), Qt::Vertical, and visualIndex().
|
overrideprotectedvirtual |
\reimp
Empty implementation because the header doesn't show QModelIndex items.
Implements QAbstractItemView.
Definition at line 3217 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 730 of file qheaderview.cpp.
References d, emit, logicalIndex(), Q_ASSERT, qMoveRange(), sectionMoved(), stretchLastSection, updateSection(), and visualIndex().
Referenced by mouseReleaseEvent().
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 418 of file qheaderview.cpp.
References d.
Referenced by QTreeView::drawRow(), and QTableView::paintEvent().
Qt::Orientation QHeaderView::orientation | ( | ) | const |
Returns the orientation of the header.
Definition at line 405 of file qheaderview.cpp.
References d.
Referenced by QHeaderView(), QHeaderView(), dataChanged(), QAbstractItemView::doAutoScroll(), headerDataChanged(), and logicalIndexAt().
|
overrideprotected |
\reimp
Definition at line 2429 of file qheaderview.cpp.
References QRect::bottom(), QVariant::canConvert(), QStyle::CE_HeaderEmptyArea, count(), d, e, QPainter::fillRect(), Qt::FontRole, Qt::Horizontal, i, QStyleOption::initFrom(), QVariant::isValid(), QRect::left(), logicalIndex(), opt, painter, paintSection(), qMax(), qMin(), QStyleOption::rect, QPainter::restore(), QRect::right(), QPainter::save(), sectionSize(), sectionViewportPosition(), QPainter::setFont(), QRect::setRect(), QStyleOption::state, QStyle::State_Horizontal, QRect::top(), QRect::translate(), variant, and visualIndexAt().
|
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 2988 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().
|
overridevirtual |
\reimp
Reimplemented from QAbstractItemView.
Definition at line 1799 of file qheaderview.cpp.
References d, initializeSections(), and QAbstractItemView::reset().
void QHeaderView::resetDefaultSectionSize | ( | ) |
Definition at line 1565 of file qheaderview.cpp.
References d.
int QHeaderView::resizeContentsPrecision | ( | ) | const |
Definition at line 1316 of file qheaderview.cpp.
References d.
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 853 of file qheaderview.cpp.
References count(), d, emit, Qt::Horizontal, isSectionHidden(), maximumSectionSize, maxSizeSection, minimumSectionSize, parent, pos, qBound(), QHeaderViewPrivate::ResizeSection, sectionResized(), sectionViewportPosition(), stretchLastSection, and visualIndex().
Referenced by QFileDialogPrivate::createWidgets(), mouseMoveEvent(), setMaximumSectionSize(), setMinimumSectionSize(), and setSectionHidden().
|
protectedslot |
Resizes the sections according to their size hints.
Normally, you do not have to call this function.
Definition at line 1868 of file qheaderview.cpp.
References d, and Interactive.
Referenced by event(), setSortIndicator(), setSortIndicatorShown(), setStretchLastSection(), and viewportEvent().
void QHeaderView::resizeSections | ( | QHeaderView::ResizeMode | mode | ) |
Resizes the sections according to the given mode, ignoring the current resize mode.
Definition at line 933 of file qheaderview.cpp.
References d.
bool QHeaderView::restoreState | ( | const QByteArray & | state | ) |
true
if the state was restored; otherwise returns false.Definition at line 1765 of file qheaderview.cpp.
References d, emit, QDataStream::Ok, QDataStream::Qt_5_0, QDataStream::Qt_6_0, QIODeviceBase::ReadOnly, sortIndicatorChanged(), QAbstractItemView::state(), and QHeaderViewPrivate::VersionMarker.
Referenced by QFileDialogPrivate::restoreWidgetState().
|
overrideprotectedvirtual |
\reimp
Empty implementation because the header doesn't show QModelIndex items.
Reimplemented from QAbstractItemView.
Definition at line 3157 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 1745 of file qheaderview.cpp.
References d, QDataStream::Qt_5_0, QHeaderViewPrivate::VersionMarker, and QIODeviceBase::WriteOnly.
|
overrideprotected |
|
overrideprotectedvirtual |
\reimp
Empty implementation because the header doesn't show QModelIndex items.
Implements QAbstractItemView.
Definition at line 3181 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.
Referenced by mouseReleaseEvent().
|
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.
Referenced by initializeSections(), initializeSections(), and sectionsInserted().
|
signal |
This signal is emitted when a section is double-clicked.
The section's logical index is specified by logicalIndex.
Referenced by mouseDoubleClickEvent().
|
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.
Referenced by mouseMoveEvent().
|
signal |
This signal is emitted when a section is double-clicked.
The section's logical index is specified by logicalIndex.
Referenced by mouseDoubleClickEvent().
|
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.
Referenced by moveSection(), and swapSections().
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 656 of file qheaderview.cpp.
References d, logicalIndex(), and visualIndex().
Referenced by QTreeView::drawRow(), and sectionViewportPosition().
|
signal |
This signal is emitted when a section is pressed.
The section's logical index is specified by logicalIndex.
Referenced by mousePressEvent().
|
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.
Referenced by resizeSection().
QHeaderView::ResizeMode QHeaderView::sectionResizeMode | ( | int | logicalIndex | ) | const |
Returns the resize mode that applies to the section specified by the given logicalIndex.
Definition at line 1271 of file qheaderview.cpp.
References d, Fixed, logicalIndex(), and visualIndex().
Referenced by dataChanged(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), and setSortIndicator().
|
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 1989 of file qheaderview.cpp.
References parent, and Q_UNUSED.
Referenced by setModel().
bool QHeaderView::sectionsClickable | ( | ) | const |
Returns true
if the header is clickable; otherwise returns false
. A clickable header could be set up to allow the user to change the representation of the data in the view related to the header.
Definition at line 1188 of file qheaderview.cpp.
References d.
bool QHeaderView::sectionsHidden | ( | ) | const |
Returns true
if sections in the header has been hidden; otherwise returns false;
Definition at line 1729 of file qheaderview.cpp.
References d.
Referenced by QTableView::paintEvent().
|
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 1884 of file qheaderview.cpp.
References count(), d, emit, i, it, j, parent, Q_ASSERT, QHeaderViewPrivate::ResizeSection, ResizeToContents, sectionCountChanged(), Stretch, and stretchLastSection.
Referenced by setModel().
int QHeaderView::sectionSize | ( | int | logicalIndex | ) | const |
Returns the width (or height for vertical headers) of the given logicalIndex.
Definition at line 631 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().
|
protectedvirtual |
Returns the size of the contents of the section specified by the given logicalIndex.
Definition at line 3025 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().
int QHeaderView::sectionSizeHint | ( | int | logicalIndex | ) | const |
Returns a suitable size hint for the section specified by logicalIndex.
Definition at line 558 of file qheaderview.cpp.
References count(), d, hint(), Qt::Horizontal, isSectionHidden(), logicalIndex(), maximumSectionSize, minimumSectionSize, qBound(), sectionSizeFromContents(), and Qt::SizeHintRole.
bool QHeaderView::sectionsMovable | ( | ) | const |
Returns true
if the header can be moved by the user; otherwise returns false.
By default, sections are movable in QTreeView (except for the first one), and not movable in QTableView.
Definition at line 1121 of file qheaderview.cpp.
References d.
bool QHeaderView::sectionsMoved | ( | ) | const |
Returns true
if sections in the header has been moved; otherwise returns false;.
Definition at line 1715 of file qheaderview.cpp.
References d.
Referenced by QTableViewPrivate::drawAndClipSpans(), QTreeView::drawRow(), QTableViewPrivate::intersectedRect(), QTableViewPrivate::selectColumn(), QTableViewPrivate::selectRow(), QTableView::setSelection(), and QTableView::visualRegionForSelection().
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 676 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().
void QHeaderView::setCascadingSectionResizes | ( | bool | enable | ) |
Definition at line 1531 of file qheaderview.cpp.
References d.
void QHeaderView::setDefaultAlignment | ( | Qt::Alignment | alignment | ) |
Definition at line 1690 of file qheaderview.cpp.
Referenced by QTreeViewPrivate::initialize().
void QHeaderView::setDefaultSectionSize | ( | int | size | ) |
Definition at line 1557 of file qheaderview.cpp.
References d, and maxSizeSection.
void QHeaderView::setFirstSectionMovable | ( | bool | movable | ) |
Definition at line 1151 of file qheaderview.cpp.
References d.
void QHeaderView::setHighlightSections | ( | bool | highlight | ) |
Definition at line 1194 of file qheaderview.cpp.
References d.
Referenced by QTableViewPrivate::init().
void QHeaderView::setMaximumSectionSize | ( | int | size | ) |
Definition at line 1647 of file qheaderview.cpp.
References d, logicalIndex(), maxSizeSection, minimumSectionSize, and resizeSection().
Referenced by setMinimumSectionSize().
void QHeaderView::setMinimumSectionSize | ( | int | size | ) |
Definition at line 1599 of file qheaderview.cpp.
References d, logicalIndex(), maximumSectionSize, maxSizeSection, resizeSection(), and setMaximumSectionSize().
|
overridevirtual |
\reimp
Reimplemented from QAbstractItemView.
Definition at line 319 of file qheaderview.cpp.
References QObject::connect(), d, QObject::disconnect(), headerDataChanged(), Qt::Horizontal, initializeSections(), QAbstractItemView::model(), QHeaderViewPrivate::NoClear, QHeaderViewPrivate::NoState, QAbstractItemView::rowsAboutToBeRemoved(), QAbstractItemView::rowsInserted(), sectionsAboutToBeRemoved(), sectionsInserted(), QAbstractItemView::setModel(), SIGNAL, SLOT, and QAbstractItemModelPrivate::staticEmptyModel().
Referenced by main().
|
slot |
Sets the header's offset to offset.
Definition at line 432 of file qheaderview.cpp.
References d, Qt::Horizontal, QCursor::pos(), QHeaderViewPrivate::ResizeSection, QCursor::setPos(), QPoint::x(), and QPoint::y().
Referenced by setOffsetToLastSection(), and setOffsetToSectionPosition().
|
slot |
Definition at line 477 of file qheaderview.cpp.
References d, Qt::Horizontal, length(), position(), setOffset(), and viewport().
|
slot |
Definition at line 462 of file qheaderview.cpp.
References d, position(), and setOffset().
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 1302 of file qheaderview.cpp.
References d.
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 993 of file qheaderview.cpp.
References count(), d, hide(), logicalIndex(), Q_ASSERT, resizeSection(), stretchLastSection, and visualIndex().
Referenced by hideSection(), and showSection().
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 1240 of file qheaderview.cpp.
References d, logicalIndex(), QHeaderViewPrivate::NoState, Q_ASSERT, ResizeToContents, Stretch, and visualIndex().
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 1215 of file qheaderview.cpp.
References count(), d, initializeSections(), ResizeToContents, and Stretch.
void QHeaderView::setSectionsClickable | ( | bool | clickable | ) |
If clickable is true, the header will respond to single clicks.
Definition at line 1172 of file qheaderview.cpp.
References d.
Referenced by QTreeWidget::QTreeWidget(), QTableViewPrivate::init(), and QTreeView::setSortingEnabled().
void QHeaderView::setSectionsMovable | ( | bool | movable | ) |
If movable 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 1103 of file qheaderview.cpp.
References d.
Referenced by QTreeViewPrivate::initialize().
|
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 3231 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 1382 of file qheaderview.cpp.
References d, emit, logicalIndex(), resizeSections(), ResizeToContents, sectionResizeMode(), sortIndicatorChanged(), and updateSection().
Referenced by QFileDialogTreeView::setFileDialogPrivate(), QTreeWidget::sortItems(), and QTableWidget::sortItems().
void QHeaderView::setSortIndicatorClearable | ( | bool | clearable | ) |
Definition at line 1459 of file qheaderview.cpp.
References d, emit, and sortIndicatorClearableChanged().
void QHeaderView::setSortIndicatorShown | ( | bool | show | ) |
Definition at line 1347 of file qheaderview.cpp.
References count(), d, resizeSections(), ResizeToContents, show(), and sortIndicatorSection().
Referenced by QTableView::setSortingEnabled(), and QTreeView::setSortingEnabled().
void QHeaderView::setStretchLastSection | ( | bool | stretch | ) |
Definition at line 1495 of file qheaderview.cpp.
References d, QHeaderViewPrivate::NoState, and resizeSections().
Referenced by QTreeViewPrivate::initialize(), and QFileDialogTreeView::setFileDialogPrivate().
|
override |
\reimp
Definition at line 539 of file qheaderview.cpp.
References isVisible(), and parent.
Referenced by QtPrivate::QCalendarView::QCalendarView().
|
inline |
Shows the section specified by logicalIndex.
Definition at line 232 of file qheaderview.h.
References setSectionHidden().
|
override |
Returns a suitable size hint for this header.
Definition at line 506 of file qheaderview.cpp.
References count(), d, hint(), i, isSectionHidden(), j, qMax(), and sectionSizeFromContents().
Referenced by QFileDialogTreeView::sizeHint().
|
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.
Referenced by restoreState(), and setSortIndicator().
|
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 1433 of file qheaderview.cpp.
References d.
Referenced by QTableWidgetPrivate::_q_dataChanged(), QTreeWidgetPrivate::_q_dataChanged(), QTableWidgetPrivate::_q_sort(), QTreeWidgetPrivate::_q_sort(), and initStyleOptionForIndex().
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 1420 of file qheaderview.cpp.
References d.
Referenced by QTableWidgetPrivate::_q_dataChanged(), QTreeWidgetPrivate::_q_dataChanged(), QTableWidgetPrivate::_q_sort(), QTreeWidgetPrivate::_q_sort(), initStyleOptionForIndex(), setSortIndicatorShown(), and QTreeWidget::sortColumn().
bool QHeaderView::stretchLastSection | ( | ) | const |
Definition at line 1489 of file qheaderview.cpp.
References d.
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 1332 of file qheaderview.cpp.
References d.
void QHeaderView::swapSections | ( | int | first, |
int | second | ||
) |
Definition at line 792 of file qheaderview.cpp.
References d, emit, QHeaderViewPrivate::ResizeSection, sectionMoved(), stretchLastSection, and visualIndex().
|
overrideprotectedvirtual |
\reimp
Reimplemented from QAbstractItemView.
Definition at line 3096 of file qheaderview.cpp.
References d.
|
protectedslot |
Updates the section specified by the given logicalIndex.
Definition at line 1852 of file qheaderview.cpp.
References d, Qt::Horizontal, logicalIndex(), sectionSize(), and sectionViewportPosition().
Referenced by event(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), moveSection(), and setSortIndicator().
|
overrideprotectedvirtual |
Returns the vertical offset of the header.
This is 0 for horizontal headers.
Implements QAbstractItemView.
Definition at line 3083 of file qheaderview.cpp.
References d, and Qt::Vertical.
|
overrideprotected |
\reimp
Definition at line 2797 of file qheaderview.cpp.
References QEvent::ContextMenu, d, e, emit, QEvent::FontChange, geometriesChanged(), QHelpEvent::globalPos(), QEvent::Hide, QString::isEmpty(), QVariant::isValid(), logicalIndexAt(), QHeaderViewPrivate::NoState, parent, QHelpEvent::pos(), Q_FALLTHROUGH, QEvent::QueryWhatsThis, QEvent::Resize, resizeSections(), QCoreApplication::sendEvent(), QEvent::Show, QWhatsThis::showText(), QToolTip::showText(), QEvent::StatusTip, Qt::StatusTipRole, QEvent::StyleChange, QEvent::ToolTip, Qt::ToolTipRole, QVariant::toString(), variant, QAbstractItemView::viewportEvent(), QEvent::WhatsThis, Qt::WhatsThisRole, and QEvent::Wheel.
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 1055 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().
int QHeaderView::visualIndexAt | ( | int | position | ) | const |
Returns the visual index of the section that covers the given position in the viewport.
Definition at line 582 of file qheaderview.cpp.
References d, and position().
Referenced by logicalIndexAt(), mouseMoveEvent(), paintEvent(), QTableView::paintEvent(), and QTreeViewPrivate::startAndEndColumns().
|
overrideprotectedvirtual |
\reimp
Empty implementation because the header doesn't show QModelIndex items.
Implements QAbstractItemView.
Definition at line 3169 of file qheaderview.cpp.
|
overrideprotectedvirtual |
Implements QAbstractItemView.
Definition at line 3240 of file qheaderview.cpp.
References count(), d, Qt::Horizontal, logicalIndex(), sectionSize(), sectionViewportPosition(), selection, and visualIndex().
|
friend |
Definition at line 208 of file qheaderview.h.
|
friend |
Definition at line 209 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 235 of file qheaderview.h.
|
readwrite |
the default alignment of the text in each header section
Definition at line 235 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 235 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 235 of file qheaderview.h.
|
readwrite |
whether the sections containing selected items are highlighted
By default, this property is false
.
Definition at line 235 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 235 of file qheaderview.h.
Referenced by mouseMoveEvent(), resizeSection(), sectionSizeHint(), and setMinimumSectionSize().
|
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 235 of file qheaderview.h.
Referenced by mouseMoveEvent(), resizeSection(), sectionSizeHint(), and setMaximumSectionSize().
|
readwrite |
whether the sort indicator is shown
By default, this property is false
.
Definition at line 235 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 235 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 235 of file qheaderview.h.
Referenced by initializeSections(), moveSection(), resizeSection(), sectionsInserted(), setSectionHidden(), and swapSections().