QHeaderView 类

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

头: #include <QHeaderView>
qmake: QT += widgets
继承: QAbstractItemView

公共类型

enum ResizeMode { Interactive, Fixed, Stretch, ResizeToContents, Custom }

特性

公共函数

QHeaderView (Qt::Orientation orientation , QWidget * parent = Q_NULLPTR)
virtual ~QHeaderView ()
bool cascadingSectionResizes () const
int count () const
Qt::Alignment defaultAlignment () const
int defaultSectionSize () const
int hiddenSectionCount () const
void hideSection (int logicalIndex )
bool highlightSections () const
bool isSectionHidden (int logicalIndex ) const
bool isSortIndicatorShown () const
int length () const
int logicalIndex (int visualIndex ) const
int logicalIndexAt (int position ) const
int logicalIndexAt (int x , int y ) const
int logicalIndexAt (const QPoint & pos ) const
int maximumSectionSize () const
int minimumSectionSize () const
void moveSection (int from , int to )
int offset () const
Qt::Orientation orientation () const
void resetDefaultSectionSize ()
int resizeContentsPrecision () const
void resizeSection (int logicalIndex , int size )
void resizeSections (QHeaderView::ResizeMode mode )
bool restoreState (const QByteArray & state )
QByteArray saveState () const
int sectionPosition (int logicalIndex ) const
ResizeMode sectionResizeMode (int logicalIndex ) const
int sectionSize (int logicalIndex ) const
int sectionSizeHint (int logicalIndex ) const
int sectionViewportPosition (int logicalIndex ) const
bool sectionsClickable () const
bool sectionsHidden () const
bool sectionsMovable () const
bool sectionsMoved () const
void setCascadingSectionResizes (bool enable )
void setDefaultAlignment (Qt::Alignment alignment )
void setDefaultSectionSize (int size )
void setHighlightSections (bool highlight )
void setMaximumSectionSize (int size )
void setMinimumSectionSize (int size )
void setResizeContentsPrecision (int precision )
void setSectionHidden (int logicalIndex , bool hide )
void setSectionResizeMode (ResizeMode mode )
void setSectionResizeMode (int logicalIndex , ResizeMode mode )
void setSectionsClickable (bool clickable )
void setSectionsMovable (bool movable )
void setSortIndicator (int logicalIndex , Qt::SortOrder order )
void setSortIndicatorShown (bool show )
void setStretchLastSection (bool stretch )
void showSection (int logicalIndex )
Qt::SortOrder sortIndicatorOrder () const
int sortIndicatorSection () const
bool stretchLastSection () const
int stretchSectionCount () const
void swapSections (int first , int second )
int visualIndex (int logicalIndex ) const
int visualIndexAt (int position ) const

重实现公共函数

virtual void reset ()
virtual void setModel (QAbstractItemModel * model )
virtual void setVisible (bool v )
virtual QSize sizeHint () const

公共槽

void headerDataChanged (Qt::Orientation orientation , int logicalFirst , int logicalLast )
void setOffset (int offset )
void setOffsetToLastSection ()
void setOffsetToSectionPosition (int visualSectionNumber )

信号

void geometriesChanged ()
void sectionClicked (int logicalIndex )
void sectionCountChanged (int oldCount , int newCount )
void sectionDoubleClicked (int logicalIndex )
void sectionEntered (int logicalIndex )
void sectionHandleDoubleClicked (int logicalIndex )
void sectionMoved (int logicalIndex , int oldVisualIndex , int newVisualIndex )
void sectionPressed (int logicalIndex )
void sectionResized (int logicalIndex , int oldSize , int newSize )
void sortIndicatorChanged (int logicalIndex , Qt::SortOrder order )

保护函数

void initStyleOption (QStyleOptionHeader * option ) const
virtual void paintSection (QPainter * painter , const QRect & rect , int logicalIndex ) const
virtual QSize sectionSizeFromContents (int logicalIndex ) const

重实现保护函数

virtual void currentChanged (const QModelIndex & current , const QModelIndex & old )
virtual bool event (QEvent * e )
virtual int horizontalOffset () const
virtual void mouseDoubleClickEvent (QMouseEvent * e )
virtual void mouseMoveEvent (QMouseEvent * e )
virtual void mousePressEvent (QMouseEvent * e )
virtual void mouseReleaseEvent (QMouseEvent * e )
virtual void paintEvent (QPaintEvent * e )
virtual void setSelection (const QRect & rect , QItemSelectionModel::SelectionFlags flags )
virtual int verticalOffset () const
virtual bool viewportEvent (QEvent * e )

保护槽

void resizeSections ()
void sectionsAboutToBeRemoved (const QModelIndex & parent , int logicalFirst , int logicalLast )
void sectionsInserted (const QModelIndex & parent , int logicalFirst , int logicalLast )

额外继承成员

详细描述

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

A QHeaderView displays the headers used in item views such as the QTableView and QTreeView 类。它取代 Qt3 的 QHeader 类以前用于相同目的,但根据项视图类使用 Qt 的模型/视图体系结构。

QHeaderView 类是一种 模型/视图类 且属于 Qt 的 模型/视图框架 .

头从模型获取每区间数据使用 QAbstractItemModel::headerData () 函数。可以设置数据通过使用 QAbstractItemModel::setHeaderData ().

每个头有 orientation () 和许多区间,给定通过 count () 函数。区间引用头的一部分 - 行或列取决于取向。

区间可以被移动和重置尺寸使用 moveSection () 和 resizeSection ();它们还可以被隐藏和展示采用 hideSection () 和 showSection ().

头的每区间由区间 ID 描述,指定通过其 section(),且可以位于特定 visualIndex () 在头中。区间可以有排序指示器设置采用 setSortIndicator ();这指示关联项视图中的项是否将按区间给出的次序进行排序。

对于水平头,区间相当于模型列,对于垂直头,区间相当于模型行。

移动 Header 头区间

头位置可以固定,或使之可移动采用 setSectionsMovable ()。可以使之可点击采用 setSectionsClickable (),和拥有重置大小行为根据 setSectionResizeMode ().

注意: 双击头调整区间尺寸仅适用于可见行。

头将发射 sectionMoved () 若用户移动区间, sectionResized () 若用户调整区间尺寸,和 sectionClicked () 及 sectionHandleDoubleClicked () 响应鼠标点击。头还会发射 sectionCountChanged ().

可以标识区间使用 logicalIndex () 和 logicalIndexAt () 函数,或通过其索引位置,使用 visualIndex () 和 visualIndexAt () 函数。视觉索引会改变若区间被移动,但逻辑索引不会改变。

外观

QTableWidget and QTableView 创建默认头。若希望头可见,可以使用 setVisible() .

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

注意: 每个头为每区间本身渲染数据,且不依赖委托。因此,调用头的 setItemDelegate () 函数不起作用。

另请参阅 模型/视图编程 , QListView , QTableView ,和 QTreeView .

成员类型文档编制

enum QHeaderView:: ResizeMode

重置尺寸模式指定头区间的行为。可以被设置在整个头视图或单个区间使用 setSectionResizeMode ().

常量 描述
QHeaderView::Interactive 0 用户可以调整区间大小。也可以按编程方式调整区间大小使用 resizeSection ()。区间尺寸默认为 defaultSectionSize 。(另请参阅 cascadingSectionResizes .)
QHeaderView::Fixed 2 用户无法调整区间大小。只可以按编程方式调整区间大小使用 resizeSection ()。区间尺寸默认为 defaultSectionSize .
QHeaderView::Stretch 1 QHeaderView 会自动调整区间大小以填充可用空间。尺寸无法被改变由用户或按编程方式。
QHeaderView::ResizeToContents 3 QHeaderView 将基于整列 (或整行) 内容自动把区间尺寸调整到最优大小。尺寸无法被改变由用户或按编程方式。(该值在 4.2 引入)

以下值已过时:

常量 描述
QHeaderView::Custom Fixed 使用 Fixed 代替。

另请参阅 setResizeMode (), setSectionResizeMode (), stretchLastSection ,和 minimumSectionSize .

特性文档编制

cascadingSectionResizes : bool

此特性保持一旦用户调整区间大小到达最小尺寸时是否就把交互重置尺寸级联到紧随区间

此特性只影响区间拥有 Interactive 作为其重置尺寸模式。

默认值为 false。

该特性在 Qt 4.2 引入。

访问函数:

bool cascadingSectionResizes () const
void setCascadingSectionResizes (bool enable )

另请参阅 setSectionResizeMode ().

defaultAlignment : Qt::Alignment

此特性保持在每个头区间中文本的默认对齐方式

该特性在 Qt 4.1 引入。

访问函数:

Qt::Alignment defaultAlignment () const
void setDefaultAlignment (Qt::Alignment alignment )

defaultSectionSize : int

此特性保持头区间的默认大小,在重置尺寸之前。

此特性只影响区间拥有 Interactive or Fixed 作为其重置尺寸模式。

默认情况下,此特性的值从属样式。因此,当样式改变时,此特性随之更新。调用 setDefaultSectionSize() 停止更新,调用 resetDefaultSectionSize() 将还原默认行为。

访问函数:

int defaultSectionSize () const
void setDefaultSectionSize (int size )
void resetDefaultSectionSize ()

另请参阅 setSectionResizeMode () 和 minimumSectionSize .

highlightSections : bool

此特性保持包含选中项的区间是否被突显

默认情况下此特性为 false .

访问函数:

bool highlightSections () const
void setHighlightSections (bool highlight )

maximumSectionSize : int

此特性保持头区间的最大尺寸。

最大区间尺寸是允许的最大区间尺寸。此特性的默认值为 1048575,也是区间的最大可能尺寸。把最大设为 -1 将重置尺寸值到最大区间尺寸。

除拉伸外,此特性被承兑由所有 重置大小模式

该特性在 Qt 5.2 引入。

访问函数:

int maximumSectionSize () const
void setMaximumSectionSize (int size )

另请参阅 setSectionResizeMode () 和 defaultSectionSize .

minimumSectionSize : int

此特性保持头区间的最小尺寸。

最小区间尺寸是允许的最小区间尺寸。若最小区间尺寸被设为 -1, QHeaderView 将使用最大的 全局结构 字体规格 尺寸。

此特性被承兑由所有 重置大小模式 .

该特性在 Qt 4.2 引入。

访问函数:

int minimumSectionSize () const
void setMinimumSectionSize (int size )

另请参阅 setSectionResizeMode () 和 defaultSectionSize .

showSortIndicator : bool

此特性保持是否展示排序指示器

默认情况下此特性为 false .

访问函数:

bool isSortIndicatorShown () const
void setSortIndicatorShown (bool show )

另请参阅 setSectionsClickable ().

stretchLastSection : bool

此特性保持头最后可见区间是否占用所有可用空间

默认值为 false。

注意: 水平头提供由 QTreeView 此特性配置被设为 true,确保视图不浪费为 Header 头部赋值的任何空间。若此值被设为 true,此特性将覆盖 Header 头部最后区间设置的重置尺寸模式。

访问函数:

bool stretchLastSection () const
void setStretchLastSection (bool stretch )

另请参阅 setSectionResizeMode ().

成员函数文档编制

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

创建新通用头采用给定 orientation and parent .

[virtual] QHeaderView:: ~QHeaderView ()

销毁 Header 头。

int QHeaderView:: count () const

返回 Header 头的区间数。

另请参阅 sectionCountChanged () 和 length ().

[virtual protected] void QHeaderView:: currentChanged (const QModelIndex & current , const QModelIndex & old )

重实现自 QAbstractItemView::currentChanged ().

[virtual protected] bool QHeaderView:: event ( QEvent * e )

重实现自 QObject::event ().

[signal] void QHeaderView:: geometriesChanged ()

此信号被发射当头几何体有改变时。

该函数在 Qt 4.2 引入。

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

更新改变头区间采用给定 orientation ,从 logicalFirst to logicalLast 包含在内。

int QHeaderView:: hiddenSectionCount () const

返回已隐藏的头区间数。

该函数在 Qt 4.1 引入。

另请参阅 setSectionHidden () 和 isSectionHidden ().

void QHeaderView:: hideSection ( int logicalIndex )

Hides the section specified by logicalIndex .

另请参阅 showSection (), isSectionHidden (), hiddenSectionCount (),和 setSectionHidden ().

[virtual protected] int QHeaderView:: horizontalOffset () const

重实现自 QAbstractItemView::horizontalOffset ().

Returns the horizontal offset of the header. This is 0 for vertical headers.

另请参阅 offset ().

[protected] void QHeaderView:: initStyleOption ( QStyleOptionHeader * option ) const

初始化 option 采用值来自此 QHeaderView 。此方法对子类是有用的,当需要 QStyleOptionHeader ,但不想自己填充所有信息。

另请参阅 QStyleOption::initFrom ().

bool QHeaderView:: isSectionHidden ( int logicalIndex ) const

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

另请参阅 hideSection (), showSection (), setSectionHidden (),和 hiddenSectionCount ().

int QHeaderView:: length () const

返回沿 Header 头方向的长度。

另请参阅 sizeHint (), setSectionResizeMode (),和 offset ().

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

注意, visualIndex is not affected by hidden sections.

另请参阅 visualIndex () 和 sectionPosition ().

int QHeaderView:: logicalIndexAt ( int position ) const

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

另请参阅 visualIndexAt () 和 isSectionHidden ().

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

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.

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

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.

另请参阅 sectionPosition ().

[virtual protected] void QHeaderView:: mouseDoubleClickEvent ( QMouseEvent * e )

重实现自 QWidget::mouseDoubleClickEvent ().

[virtual protected] void QHeaderView:: mouseMoveEvent ( QMouseEvent * e )

重实现自 QWidget::mouseMoveEvent ().

[virtual protected] void QHeaderView:: mousePressEvent ( QMouseEvent * e )

重实现自 QWidget::mousePressEvent ().

[virtual protected] void QHeaderView:: mouseReleaseEvent ( QMouseEvent * e )

重实现自 QWidget::mouseReleaseEvent ().

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

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

另请参阅 sectionsMoved ().

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.

另请参阅 setOffset ().

Qt::Orientation QHeaderView:: orientation () const

返回头的取向。

另请参阅 Qt::Orientation .

[virtual protected] void QHeaderView:: paintEvent ( QPaintEvent * e )

重实现自 QWidget::paintEvent ().

[virtual protected] void QHeaderView:: paintSection ( QPainter * painter , const QRect & rect , int logicalIndex ) const

Paints the section specified by the given logicalIndex ,使用给定 painter and rect .

通常,不必调用此函数。

[virtual] void QHeaderView:: reset ()

重实现自 QAbstractItemView::reset ().

int QHeaderView:: resizeContentsPrecision () const

Returns how precise QHeaderView will calculate on ResizeToContents .

该函数在 Qt 5.2 引入。

另请参阅 setResizeContentsPrecision () 和 setSectionResizeMode ().

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

重置指定区间尺寸为 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.

另请参阅 sectionResized (), resizeMode (), sectionSize (),和 hideSection ().

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

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

另请参阅 resizeMode () 和 sectionResized ().

[protected slot] void QHeaderView:: resizeSections ()

调整区间大小根据其大小提示。通常,不必调用此函数。

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.

该函数在 Qt 4.3 引入。

另请参阅 saveState ().

QByteArray QHeaderView:: saveState () const

保存此头视图的当前状态。

要还原保存状态,把返回值传递给 restoreState ().

该函数在 Qt 4.3 引入。

另请参阅 restoreState ().

[signal] void QHeaderView:: sectionClicked ( int logicalIndex )

此信号被发射当点击区间时。区间逻辑索引指定由 logicalIndex .

注意, sectionPressed 信号也会被发射。

另请参阅 setSectionsClickable () 和 sectionPressed ().

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

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 .

另请参阅 count (), length (),和 headerDataChanged ().

[signal] void QHeaderView:: sectionDoubleClicked ( int logicalIndex )

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

另请参阅 setSectionsClickable ().

[signal] void QHeaderView:: sectionEntered ( int logicalIndex )

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

该函数在 Qt 4.3 引入。

另请参阅 setSectionsClickable () 和 sectionPressed ().

[signal] void QHeaderView:: sectionHandleDoubleClicked ( int logicalIndex )

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

另请参阅 setSectionsClickable ().

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

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

另请参阅 moveSection ().

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.

另请参阅 sectionViewportPosition ().

[signal] void QHeaderView:: sectionPressed ( int logicalIndex )

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

另请参阅 setSectionsClickable ().

ResizeMode QHeaderView:: sectionResizeMode ( int logicalIndex ) const

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

该函数在 Qt 5.0 引入。

另请参阅 setSectionResizeMode ().

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

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

另请参阅 resizeSection ().

int QHeaderView:: sectionSize ( int logicalIndex ) const

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

另请参阅 length (), setSectionResizeMode (),和 defaultSectionSize ().

[virtual protected] QSize QHeaderView:: sectionSizeFromContents ( int logicalIndex ) const

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

另请参阅 defaultSectionSize ().

int QHeaderView:: sectionSizeHint ( int logicalIndex ) const

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

Qt::SizeHintRole

另请参阅 sizeHint (), defaultSectionSize (), minimumSectionSize (),和 maximumSectionSize ().

int QHeaderView:: sectionViewportPosition ( int logicalIndex ) const

Returns the section viewport position of the given logicalIndex .

如果区间被隐藏,返回值不确定。

另请参阅 sectionPosition () 和 isSectionHidden ().

[protected slot] void QHeaderView:: sectionsAboutToBeRemoved (const QModelIndex & parent , int logicalFirst , int logicalLast )

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.

bool QHeaderView:: sectionsClickable () const

返回 true 若 Header 头是可点击的;否则返回 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.

该函数在 Qt 5.0 引入。

另请参阅 setSectionsClickable ().

bool QHeaderView:: sectionsHidden () const

返回 true 若 Header 头区间被隐藏;否则返回 false;

该函数在 Qt 4.1 引入。

另请参阅 setSectionHidden ().

[protected slot] void QHeaderView:: sectionsInserted (const QModelIndex & parent , int logicalFirst , int logicalLast )

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.

bool QHeaderView:: sectionsMovable () const

返回 true 若 Header 头可以被用户移动;否则返回 false。

该函数在 Qt 5.0 引入。

另请参阅 setSectionsMovable ().

bool QHeaderView:: sectionsMoved () const

返回 true 若 Header 头区间已被移动;否则返回 false;

另请参阅 moveSection ().

[virtual] void QHeaderView:: setModel ( QAbstractItemModel * model )

重实现自 QAbstractItemView::setModel ().

[slot] void QHeaderView:: setOffset ( int offset )

把头的偏移设为 offset .

另请参阅 offset () 和 length ().

[slot] void QHeaderView:: setOffsetToLastSection ()

设置偏移以使最后区间可见。

该函数在 Qt 4.2 引入。

另请参阅 setOffset (), sectionPosition (),和 setOffsetToSectionPosition ().

[slot] void QHeaderView:: setOffsetToSectionPosition ( int visualSectionNumber )

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

该函数在 Qt 4.2 引入。

另请参阅 setOffset () 和 sectionPosition ().

void QHeaderView:: setResizeContentsPrecision ( int precision )

Sets how precise QHeaderView should calculate the size when ResizeToContents is used. A low value will provide a less accurate but fast auto resize while a higher value will provide a more accurate resize that however can be slow.

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

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

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

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

该函数在 Qt 5.2 引入。

另请参阅 resizeContentsPrecision (), setSectionResizeMode (), resizeSections (), QTableView::sizeHintForColumn (), QTableView::sizeHintForRow (),和 QTreeView::sizeHintForColumn ().

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

hide 为 true 区间指定通过 logicalIndex 被隐藏;否则展示区间。

另请参阅 isSectionHidden () 和 hiddenSectionCount ().

void QHeaderView:: setSectionResizeMode ( ResizeMode mode )

设置如何把头重置到哪些描述大小的约束通过给定 mode .

该函数在 Qt 5.0 引入。

另请参阅 sectionResizeMode (), resizeMode (), length (),和 sectionResized ().

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

设置区间如何被约束指定通过 logicalIndex 在头中可以重置到那些描述大小通过给定 mode 。逻辑索引应该存在,当此函数被调用时。

注意: 最后区间会忽略此设置若 stretchLastSection 特性被设为 true。这是默认的对于水平头提供通过 QTreeView .

该函数在 Qt 5.0 引入。

另请参阅 setStretchLastSection () 和 resizeContentsPrecision ().

void QHeaderView:: setSectionsClickable ( bool clickable )

clickable 为 true,头将响应单击。

该函数在 Qt 5.0 引入。

另请参阅 sectionsClickable (), sectionClicked (), sectionPressed (),和 setSortIndicatorShown ().

void QHeaderView:: setSectionsMovable ( bool movable )

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

该函数在 Qt 5.0 引入。

另请参阅 sectionsMovable () 和 sectionMoved ().

[virtual protected] void QHeaderView:: setSelection (const QRect & rect , QItemSelectionModel::SelectionFlags flags )

重实现自 QAbstractItemView::setSelection ().

Selects the items in the given rect 根据指定 flags .

基类实现什么都不做。

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.

另请参阅 sortIndicatorSection () 和 sortIndicatorOrder ().

[virtual] void QHeaderView:: setVisible ( bool v )

重实现自 QWidget::setVisible ().

void QHeaderView:: showSection ( int logicalIndex )

显示指定区间通过 logicalIndex .

另请参阅 hideSection (), isSectionHidden (), hiddenSectionCount (),和 setSectionHidden ().

[virtual] QSize QHeaderView:: sizeHint () const

重实现自 QWidget::sizeHint ().

返回此 Header 头的合适大小提示。

另请参阅 sectionSizeHint ().

[signal] void QHeaderView:: sortIndicatorChanged ( int logicalIndex , Qt::SortOrder order )

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

该函数在 Qt 4.3 引入。

另请参阅 setSortIndicator ().

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.

另请参阅 setSortIndicator () 和 sortIndicatorSection ().

int QHeaderView:: sortIndicatorSection () const

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

另请参阅 setSortIndicator (), sortIndicatorOrder (),和 setSortIndicatorShown ().

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.

该函数在 Qt 4.1 引入。

另请参阅 stretchLastSection and resizeMode ().

void QHeaderView:: swapSections ( int first , int second )

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

该函数在 Qt 4.2 引入。

另请参阅 moveSection ().

[virtual protected] int QHeaderView:: verticalOffset () const

重实现自 QAbstractItemView::verticalOffset ().

Returns the vertical offset of the header. This is 0 for horizontal headers.

另请参阅 offset ().

[virtual protected] bool QHeaderView:: viewportEvent ( QEvent * e )

重实现自 QAbstractScrollArea::viewportEvent ().

int QHeaderView:: visualIndex ( int logicalIndex ) const

Returns the visual index position of the section specified by the given logicalIndex , or -1 otherwise.

被隐藏区间仍具有有效视觉索引。

另请参阅 logicalIndex ().

int QHeaderView:: visualIndexAt ( int position ) const

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

另请参阅 logicalIndexAt ().