The QHeaderView 類為項視圖提供 Header 頭部行 (或 Header 頭部列)。 更多...
| 頭: | #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 ) |
The QHeaderView 類為項視圖提供 Header 頭部行 (或 Header 頭部列)。
A
QHeaderView
顯示用於項視圖的 Header 頭部,譬如
QTableView
and
QTreeView
類。它取代 Qt3 的
QHeader
類以前用於相同目的,但根據項視圖類使用 Qt 的模型/視圖體係結構。
The QHeaderView 類是一種 模型/視圖類 且屬於 Qt 的 模型/視圖框架 .
頭從模型獲取每區間數據使用 QAbstractItemModel::headerData () 函數。可以設置數據通過使用 QAbstractItemModel::setHeaderData ().
每個頭有 orientation () 和許多區間,給定通過 count () 函數。區間引用頭的一部分 - 行或列取決於取嚮。
區間可以移動和重置大小使用 moveSection () 和 resizeSection ();它們還可以被隱藏和展示采用 hideSection () 和 showSection ().
頭的每區間由區間 ID 描述,指定通過其 section(),且可以位於特定 visualIndex () 在頭中。區間可以有排序指示器設置采用 setSortIndicator ();這指示關聯項視圖中的項是否將按區間給齣的次序進行排序。
對於水平頭,區間相當於模型列,對於垂直頭,區間相當於模型行。
頭位置可以固定,或使之可移動采用 setSectionsMovable ()。可以使之可點擊采用 setSectionsClickable (),和擁有重置大小行為根據 setSectionResizeMode ().
注意: 雙擊頭調整區間尺寸僅適用於可見行。
Header (頭) 將發射 sectionMoved () 若用戶移動區間, sectionResized () 若用戶調整區間尺寸,和 sectionClicked () 及 sectionHandleDoubleClicked () 響應鼠標點擊。頭還會發射 sectionCountChanged ().
可以標識區間使用 logicalIndex () 和 logicalIndexAt () 函數,或通過其索引位置,使用 visualIndex () 和 visualIndexAt () 函數。視覺索引會改變若區間被移動,但邏輯索引不會改變。
QTableWidget and QTableView 創建默認 Header (頭部)。若希望 Header (頭部) 可見,可以使用 setVisible() .
並非所有 ItemDataRole s will have an effect on a QHeaderView . If you need to draw other roles, you can subclass QHeaderView 並重實現 paintEvent() . QHeaderView respects the following item data roles: TextAlignmentRole , DisplayRole , FontRole , DecorationRole , ForegroundRole ,和 BackgroundRole .
注意: 每個頭為每區間本身渲染數據,且不依賴委托。因此,調用頭的 setItemDelegate () 函數不起作用。
另請參閱 模型/視圖編程 , QListView , QTableView ,和 QTreeView .
重置尺寸模式指定頭區間的行為。可以被設置在整個頭視圖或單個區間使用 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 .
此特性保持一旦用戶調整區間大小到達最小尺寸時是否就把交互重置尺寸級聯到緊隨區間
此特性隻影響區間擁有 Interactive 作為其重置尺寸模式。
默認值為 false。
該特性在 Qt 4.2 引入。
訪問函數:
| bool | cascadingSectionResizes () const |
| void | setCascadingSectionResizes (bool enable ) |
另請參閱 setSectionResizeMode ().
此特性保持在每個頭區間中文本的默認對齊方式
該特性在 Qt 4.1 引入。
訪問函數:
| Qt::Alignment | defaultAlignment () const |
| void | setDefaultAlignment (Qt::Alignment alignment ) |
此特性保持頭部區間的默認大小,在重置大小前。
此特性隻影響區間擁有 Interactive or Fixed 作為其重置尺寸模式。
默認情況下,此特性的值從屬樣式。因此,當樣式改變時,此特性隨之更新。調用 setDefaultSectionSize() 停止更新,調用 resetDefaultSectionSize() 將還原默認行為。
訪問函數:
| int | defaultSectionSize () const |
| void | setDefaultSectionSize (int size ) |
| void | resetDefaultSectionSize () |
另請參閱 setSectionResizeMode () 和 minimumSectionSize .
此特性保持包含選中項的區間是否被突顯
默認情況下,此特性為
false
.
訪問函數:
| bool | highlightSections () const |
| void | setHighlightSections (bool highlight ) |
此特性保持頭區間的最大尺寸。
最大區間尺寸是允許的最大區間尺寸。此特性的默認值為 1048575,也是區間的最大可能尺寸。把最大設為 -1 將重置尺寸值到最大區間尺寸。
除拉伸外,此特性被承兌由所有 重置大小模式
該特性在 Qt 5.2 引入。
訪問函數:
| int | maximumSectionSize () const |
| void | setMaximumSectionSize (int size ) |
另請參閱 setSectionResizeMode () 和 defaultSectionSize .
此特性保持頭區間的最小尺寸。
最小區間尺寸是允許的最小區間尺寸。若最小區間尺寸被設為 -1, QHeaderView 將使用最大的 全局結構 或 字體規格 尺寸。
此特性被承兌由所有 重置大小模式 .
該特性在 Qt 4.2 引入。
訪問函數:
| int | minimumSectionSize () const |
| void | setMinimumSectionSize (int size ) |
另請參閱 setSectionResizeMode () 和 defaultSectionSize .
此特性保持是否展示排序指示器
默認情況下,此特性為
false
.
訪問函數:
| bool | isSortIndicatorShown () const |
| void | setSortIndicatorShown (bool show ) |
另請參閱 setSectionsClickable ().
此特性保持 Header (頭) 中的最後一個可見區間是否占用所有可用空間
默認值為 false。
注意: 水平頭提供由 QTreeView 此特性配置被設為 true,確保視圖不浪費為其 Header (頭部) 賦值的任何空間。若此值被設為 true,此特性將覆蓋 Header (頭部) 最後區間設置的重置大小模式。
訪問函數:
| bool | stretchLastSection () const |
| void | setStretchLastSection (bool stretch ) |
另請參閱 setSectionResizeMode ().
創建新通用頭采用給定 orientation and parent .
[虛擬]
QHeaderView::
~QHeaderView
()
銷毀 Header (頭)。
返迴 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 包括在內。
返迴已隱藏的頭區間數。
該函數在 Qt 4.1 引入。
另請參閱 setSectionHidden () 和 isSectionHidden ().
隱藏區間指定通過 logicalIndex .
另請參閱 showSection (), isSectionHidden (), hiddenSectionCount (),和 setSectionHidden ().
[virtual protected]
int
QHeaderView::
horizontalOffset
() const
重實現自 QAbstractItemView::horizontalOffset ().
返迴 Header (頭部) 的水平偏移。這為 0 對於垂直頭部。
另請參閱 offset ().
[protected]
void
QHeaderView::
initStyleOption
(
QStyleOptionHeader
*
option
) const
初始化 option 采用值來自此 QHeaderView 。此方法對子類是有用的,當需要 QStyleOptionHeader ,但不想自己填充所有信息。
另請參閱 QStyleOption::initFrom ().
返迴
true
若區間指定通過
logicalIndex
被用戶明確隱藏;否則返迴
false
.
另請參閱 hideSection (), showSection (), setSectionHidden (),和 hiddenSectionCount ().
返迴沿 Header (頭) 方嚮的長度。
另請參閱 sizeHint (), setSectionResizeMode (),和 offset ().
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 ().
Returns the section that covers the given position 在視口。
另請參閱 visualIndexAt () 和 isSectionHidden ().
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.
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 ().
Moves the section at visual index from to occupy visual index to .
另請參閱 sectionsMoved ().
Returns the offset of the header: this is the header's left-most (or top-most for vertical headers) visible pixel.
另請參閱 setOffset ().
返迴頭的取嚮。
另請參閱 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 .
通常,不必調用此函數。
[虛擬]
void
QHeaderView::
reset
()
重實現自 QAbstractItemView::reset ().
Returns how precise QHeaderView will calculate on ResizeToContents .
該函數在 Qt 5.2 引入。
另請參閱 setResizeContentsPrecision () 和 setSectionResizeMode ().
重置區間大小指定通過 logicalIndex to size 度量 (以像素為單位)。尺寸參數必須是 >= 0 的值。不管怎樣,不推薦 size 等於 0。在此情況下 hideSection 應該被使用以取而代之。
另請參閱 sectionResized (), resizeMode (), sectionSize (),和 hideSection ().
Resizes the sections according to the given mode , ignoring the current resize mode.
另請參閱 resizeMode () 和 sectionResized ().
[protected slot]
void
QHeaderView::
resizeSections
()
調整區間大小根據其大小提示。通常,不必調用此函數。
還原
state
of this header view. This function returns
true
if the state was restored; otherwise returns false.
該函數在 Qt 4.3 引入。
另請參閱 saveState ().
保存此頭視圖的當前狀態。
要還原保存狀態,把返迴值傳遞給 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 ().
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 ().
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 ().
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 ().
Returns a suitable size hint for the section specified by logicalIndex .
另請參閱 sizeHint (), defaultSectionSize (), minimumSectionSize (),和 maximumSectionSize ().
返迴區間視口位置為給定 logicalIndex .
若區間被隱藏,返迴值未定義。
另請參閱 sectionPosition () 和 isSectionHidden ().
[protected slot]
void
QHeaderView::
sectionsAboutToBeRemoved
(const
QModelIndex
&
parent
,
int
logicalFirst
,
int
logicalLast
)
此槽被調用,當移除區間從 parent . logicalFirst and logicalLast signify where the sections were removed.
If only one section is removed, logicalFirst and logicalLast will be the same.
返迴
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 ().
返迴
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.
返迴
true
若 Header (頭) 可以被用戶移動;否則返迴 false。
該函數在 Qt 5.0 引入。
另請參閱 setSectionsMovable ().
返迴
true
若 Header (頭) 區間已移動;否則返迴 false;
另請參閱 moveSection ().
[虛擬]
void
QHeaderView::
setModel
(
QAbstractItemModel
*
model
)
重實現自 QAbstractItemView::setModel ().
[slot]
void
QHeaderView::
setOffset
(
int
offset
)
把 Header (頭部) 偏移設為 offset .
[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 ().
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 ().
若 hide 為 true 區間指定通過 logicalIndex 被隱藏;否則展示區間。
另請參閱 isSectionHidden () 和 hiddenSectionCount ().
設置如何把頭重置到哪些描述大小的約束通過給定 mode .
該函數在 Qt 5.0 引入。
另請參閱 sectionResizeMode (), resizeMode (), length (),和 sectionResized ().
設置區間如何被約束指定通過 logicalIndex 在 Header (頭) 中可以重置到那些描述大小通過給定 mode 。邏輯索引應該存在,當此函數被調用時。
注意: 最後區間會忽略此設置若 stretchLastSection 特性被設為 true。這是默認的對於水平頭提供通過 QTreeView .
該函數在 Qt 5.0 引入。
另請參閱 setStretchLastSection () 和 resizeContentsPrecision ().
若 clickable 為 true,頭將響應單擊。
該函數在 Qt 5.0 引入。
另請參閱 sectionsClickable (), sectionClicked (), sectionPressed (),和 setSortIndicatorShown ().
若 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 .
基類實現什麼都不做。
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 可以是 -1,在這種情況下,不會展示排序指示器,且模型將返迴其自然、未排序次序。注意,所有模型並非都支持這,且在這種情況下甚至可能崩潰。
另請參閱 sortIndicatorSection () 和 sortIndicatorOrder ().
[虛擬]
void
QHeaderView::
setVisible
(
bool
v
)
重實現自 QWidget::setVisible ().
顯示指定區間通過 logicalIndex .
另請參閱 hideSection (), isSectionHidden (), hiddenSectionCount (),和 setSectionHidden ().
[虛擬]
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 ().
Returns the order for the sort indicator. If no section has a sort indicator the return value of this function is undefined.
另請參閱 setSortIndicator () 和 sortIndicatorSection ().
Returns the logical index of the section that has a sort indicator. By default this is section 0.
另請參閱 setSortIndicator (), sortIndicatorOrder (),和 setSortIndicatorShown ().
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 ().
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 ().
返迴 Header (頭) 的垂直偏移。水平頭這為 0。
另請參閱 offset ().
[virtual protected]
bool
QHeaderView::
viewportEvent
(
QEvent
*
e
)
重實現自 QAbstractScrollArea::viewportEvent ().
Returns the visual index position of the section specified by the given logicalIndex ,否則 -1。
被隱藏區間仍具有有效視覺索引。
另請參閱 logicalIndex ().
Returns the visual index of the section that covers the given position 在視口。
另請參閱 logicalIndexAt ().