QHeaderView Class
The 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 } |
属性
|
|
- 16 个属性继承自 QAbstractItemView
- 3 个属性继承自 QAbstractScrollArea
- 6 个属性继承自 QFrame
- 59 个属性继承自 QWidget
- 1 个属性继承自 QObject
公有函数
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 |
- 59 个公有函数继承自 QAbstractItemView
- 20 个公有函数继承自 QAbstractScrollArea
- 14 个公有函数继承自 QFrame
- 214 个公有函数继承自 QWidget
- 32 个公有函数继承自 QObject
- 14 个公有函数继承自 QPaintDevice
公有槽函数
void | headerDataChanged(Qt::Orientation orientation, int logicalFirst, int logicalLast) |
void | setOffset(int offset) |
void | setOffsetToLastSection() |
void | setOffsetToSectionPosition(int visualSectionNumber) |
- 9 个公有槽函数继承自 QAbstractItemView
- 19 个公有槽函数继承自 QWidget
- 1 个公有槽函数继承自 QObject
信号
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) |
- 7 个信号继承自 QAbstractItemView
- 3 个信号继承自 QWidget
- 2 个信号继承自 QObject
受保护的函数
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 ¤t, 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) |
- 37 个受保护的函数继承自 QAbstractItemView
- 20 个受保护的函数继承自 QAbstractScrollArea
- 4 个受保护的函数继承自 QFrame
- 35 个受保护的函数继承自 QWidget
- 9 个受保护的函数继承自 QObject
- 1 个受保护的函数继承自 QPaintDevice
Protected Slots
void | resizeSections() |
void | sectionsAboutToBeRemoved(const QModelIndex &parent, int logicalFirst, int logicalLast) |
void | sectionsInserted(const QModelIndex &parent, int logicalFirst, int logicalLast) |
- 9 个受保护的槽函数继承自 QAbstractItemView
- 1 个受保护的槽函数继承自 QWidget
其他继承的成员
- 1 个公有变量继承自 QObject
- 5 个静态公有成员继承自 QWidget
- 10 个静态公有成员继承自 QObject
- 2 个受保护的变量继承自 QObject
- 1 protected type inherited from QPaintDevice
详细描述
The 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 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 Model/View Classes and is part of Qt's 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.
Moving Header Sections
A header can be fixed in place, or made movable with setSectionsMovable(). It can be made clickable with setSectionsClickable(), and has resizing behavior in accordance with setSectionResizeMode().
Note: Double-clicking on a header to resize a section only applies for visible rows.
A header will emit sectionMoved() if the user moves a section, sectionResized() if the user resizes a section, and sectionClicked() as well as sectionHandleDoubleClicked() in response to mouse clicks. A header will also emit sectionCountChanged().
You can identify a section using the logicalIndex() and logicalIndexAt() functions, or by its index position, using the visualIndex() and visualIndexAt() functions. The visual index will change if a section is moved, but the logical index will not change.
Appearance
QTableWidget and QTableView create default headers. If you want the headers to be visible, you can use setVisible().
Not all ItemDataRoles 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, and BackgroundRole.
Note: Each header renders the data for each section itself, and does not rely on a delegate. As a result, calling a header's setItemDelegate() function will have no effect.
参见 Model/View Programming, QListView, QTableView, and QTreeView.
成员类型
enum QHeaderView::ResizeMode
The resize mode specifies the behavior of the header sections. It can be set on the entire header view or on individual sections using setSectionResizeMode().
Constant | Value | Description |
---|---|---|
QHeaderView::Interactive | 0 | The user can resize the section. The section can also be resized programmatically using resizeSection(). The section size defaults to defaultSectionSize. (See also cascadingSectionResizes.) |
QHeaderView::Fixed | 2 | The user cannot resize the section. The section can only be resized programmatically using resizeSection(). The section size defaults to defaultSectionSize. |
QHeaderView::Stretch | 1 | QHeaderView will automatically resize the section to fill the available space. The size cannot be changed by the user or programmatically. |
QHeaderView::ResizeToContents | 3 | 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:
Constant | Value | Description |
---|---|---|
QHeaderView::Custom | Fixed | Use Fixed instead. |
参见 setResizeMode(), setSectionResizeMode(), stretchLastSection, and minimumSectionSize.
属性
cascadingSectionResizes : bool
This property holds 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 Interactive as their resize mode.
The default value is false.
This property was introduced in Qt 4.2.
访问函数:
bool | cascadingSectionResizes() const |
void | setCascadingSectionResizes(bool enable) |
参见 setSectionResizeMode().
defaultAlignment : Qt::Alignment
This property holds the default alignment of the text in each header section
This property was introduced in Qt 4.1.
访问函数:
Qt::Alignment | defaultAlignment() const |
void | setDefaultAlignment(Qt::Alignment alignment) |
defaultSectionSize : int
This property holds the default size of the header sections before resizing.
This property only affects sections that have Interactive or 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.
访问函数:
int | defaultSectionSize() const |
void | setDefaultSectionSize(int size) |
void | resetDefaultSectionSize() |
参见 setSectionResizeMode() and minimumSectionSize.
highlightSections : bool
This property holds whether the sections containing selected items are highlighted
By default, this property is false
.
访问函数:
bool | highlightSections() const |
void | setHighlightSections(bool highlight) |
maximumSectionSize : int
This property holds 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 resize modes
This property was introduced in Qt 5.2.
访问函数:
int | maximumSectionSize() const |
void | setMaximumSectionSize(int size) |
参见 setSectionResizeMode() and defaultSectionSize.
minimumSectionSize : int
This property holds 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 maximum of the global strut or the font metrics size.
This property is honored by all resize modes.
This property was introduced in Qt 4.2.
访问函数:
int | minimumSectionSize() const |
void | setMinimumSectionSize(int size) |
参见 setSectionResizeMode() and defaultSectionSize.
showSortIndicator : bool
This property holds whether the sort indicator is shown
By default, this property is false
.
访问函数:
bool | isSortIndicatorShown() const |
void | setSortIndicatorShown(bool show) |
参见 setSectionsClickable().
stretchLastSection : bool
This property holds whether the last visible section in the header takes up all the available space
The default value is false.
Note: The horizontal headers provided by QTreeView are configured with this property set to true, ensuring that the view does not waste any of the space assigned to it for its header. If this value is set to true, this property will override the resize mode set on the last section in the header.
访问函数:
bool | stretchLastSection() const |
void | setStretchLastSection(bool stretch) |
参见 setSectionResizeMode().
成员函数
QHeaderView::QHeaderView(Qt::Orientation orientation, QWidget *parent = Q_NULLPTR)
Creates a new generic header with the given orientation and parent.
[virtual]
QHeaderView::~QHeaderView()
Destroys the header.
int QHeaderView::count() const
Returns the number of sections in the header.
参见 sectionCountChanged() and length().
[virtual protected]
void QHeaderView::currentChanged(const QModelIndex ¤t, const QModelIndex &old)
重新实现 QAbstractItemView::currentChanged().
[virtual protected]
bool QHeaderView::event(QEvent *e)
重新实现 QObject::event().
[signal]
void QHeaderView::geometriesChanged()
This signal is emitted when the header's geometries have changed.
This function was introduced in Qt 4.2.
[slot]
void QHeaderView::headerDataChanged(Qt::Orientation orientation, int logicalFirst, int logicalLast)
Updates the changed header sections with the given orientation, from logicalFirst to logicalLast inclusive.
int QHeaderView::hiddenSectionCount() const
Returns the number of sections in the header that has been hidden.
This function was introduced in Qt 4.1.
参见 setSectionHidden() and isSectionHidden().
void QHeaderView::hideSection(int logicalIndex)
Hides the section specified by logicalIndex.
参见 showSection(), isSectionHidden(), hiddenSectionCount(), and 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
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.
参见 QStyleOption::initFrom().
bool QHeaderView::isSectionHidden(int logicalIndex) const
Returns true
if the section specified by logicalIndex is explicitly hidden from the user; otherwise returns false
.
参见 hideSection(), showSection(), setSectionHidden(), and hiddenSectionCount().
int QHeaderView::length() const
Returns the length along the orientation of the header.
参见 sizeHint(), setSectionResizeMode(), and 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().
Note that the visualIndex is not affected by hidden sections.
参见 visualIndex() and sectionPosition().
int QHeaderView::logicalIndexAt(int position) const
Returns the section that covers the given position in the viewport.
参见 visualIndexAt() and 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
Returns the orientation of the header.
参见 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, using the given painter and rect.
Normally, you do not have to call this function.
[virtual]
void QHeaderView::reset()
重新实现 QAbstractItemView::reset().
int QHeaderView::resizeContentsPrecision() const
Returns how precise QHeaderView will calculate on ResizeToContents.
This function was introduced in Qt 5.2.
参见 setResizeContentsPrecision() and setSectionResizeMode().
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.
参见 sectionResized(), resizeMode(), sectionSize(), and hideSection().
void QHeaderView::resizeSections(QHeaderView::ResizeMode mode)
Resizes the sections according to the given mode, ignoring the current resize mode.
参见 resizeMode() and sectionResized().
[protected slot]
void QHeaderView::resizeSections()
Resizes the sections according to their size hints. Normally, you do not have to call this function.
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.
This function was introduced in Qt 4.3.
参见 saveState().
QByteArray QHeaderView::saveState() const
Saves the current state of this header view.
To restore the saved state, pass the return value to restoreState().
This function was introduced in Qt 4.3.
参见 restoreState().
[signal]
void QHeaderView::sectionClicked(int logicalIndex)
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.
参见 setSectionsClickable() and 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(), and 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.
This function was introduced in Qt 4.3.
参见 setSectionsClickable() and 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.
This function was introduced in 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(), and 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.
参见 sizeHint(), defaultSectionSize(), minimumSectionSize(), and maximumSectionSize().
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.
参见 sectionPosition() and 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
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.
This function was introduced in Qt 5.0.
参见 setSectionsClickable().
bool QHeaderView::sectionsHidden() const
Returns true
if sections in the header has been hidden; otherwise returns false;
This function was introduced in 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
Returns true
if the header can be moved by the user; otherwise returns false.
This function was introduced in Qt 5.0.
参见 setSectionsMovable().
bool QHeaderView::sectionsMoved() const
Returns true
if sections in the header has been moved; otherwise returns false;
参见 moveSection().
[virtual]
void QHeaderView::setModel(QAbstractItemModel *model)
重新实现 QAbstractItemView::setModel().
[slot]
void QHeaderView::setOffset(int offset)
Sets the header's offset to offset.
[slot]
void QHeaderView::setOffsetToLastSection()
Sets the offset to make the last section visible.
This function was introduced in Qt 4.2.
参见 setOffset(), sectionPosition(), and 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().
This function was introduced in Qt 4.2.
参见 setOffset() and 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() and QTreeView::sizeHintForColumn(). Reimplementing these functions can make this function not having an effect.
This function was introduced in Qt 5.2.
参见 resizeContentsPrecision(), setSectionResizeMode(), resizeSections(), QTableView::sizeHintForColumn(), QTableView::sizeHintForRow(), and QTreeView::sizeHintForColumn().
void QHeaderView::setSectionHidden(int logicalIndex, bool hide)
If hide is true the section specified by logicalIndex is hidden; otherwise the section is shown.
参见 isSectionHidden() and hiddenSectionCount().
void QHeaderView::setSectionResizeMode(ResizeMode mode)
Sets the constraints on how the header can be resized to those described by the given mode.
This function was introduced in Qt 5.0.
参见 sectionResizeMode(), resizeMode(), length(), and sectionResized().
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.
Note: This setting will be ignored for the last section if the stretchLastSection property is set to true. This is the default for the horizontal headers provided by QTreeView.
This function was introduced in Qt 5.0.
参见 setStretchLastSection() and resizeContentsPrecision().
void QHeaderView::setSectionsClickable(bool clickable)
If clickable is true, the header will respond to single clicks.
This function was introduced in Qt 5.0.
参见 sectionsClickable(), sectionClicked(), sectionPressed(), and setSortIndicatorShown().
void QHeaderView::setSectionsMovable(bool movable)
If movable is true, the header may be moved by the user; otherwise it is fixed in place.
This function was introduced in Qt 5.0.
参见 sectionsMovable() and sectionMoved().
[virtual protected]
void QHeaderView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags flags)
重新实现 QAbstractItemView::setSelection().
Selects the items in the given rect according to the specified flags.
The base class implementation does nothing.
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() and sortIndicatorOrder().
[virtual]
void QHeaderView::setVisible(bool v)
重新实现 QWidget::setVisible().
void QHeaderView::showSection(int logicalIndex)
Shows the section specified by logicalIndex.
参见 hideSection(), isSectionHidden(), hiddenSectionCount(), and setSectionHidden().
[virtual]
QSize QHeaderView::sizeHint() const
重新实现 QWidget::sizeHint().
Returns a suitable size hint for this 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.
This function was introduced in 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() and 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(), and 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.
This function was introduced in 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.
This function was introduced in 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.
Hidden sections still have valid visual indexes.
参见 logicalIndex().
int QHeaderView::visualIndexAt(int position) const
Returns the visual index of the section that covers the given position in the viewport.
参见 logicalIndexAt().