QHeaderView¶
The
QHeaderViewclass provides a header row or header column for item views. More…

Synopsis¶
Functions¶
def
cascadingSectionResizes()def
count()def
defaultAlignment()def
defaultSectionSize()def
hiddenSectionCount()def
hideSection(logicalIndex)def
highlightSections()def
initStyleOption(option)def
initialize()def
initializeSections()def
initializeSections(start, end)def
isFirstSectionMovable()def
isSectionHidden(logicalIndex)def
isSortIndicatorShown()def
length()def
logicalIndex(visualIndex)def
logicalIndexAt(pos)def
logicalIndexAt(position)def
logicalIndexAt(x, y)def
maximumSectionSize()def
minimumSectionSize()def
moveSection(from, to)def
offset()def
orientation()def
resetDefaultSectionSize()def
resizeContentsPrecision()def
resizeSection(logicalIndex, size)def
resizeSections(mode)def
restoreState(state)def
saveState()def
sectionPosition(logicalIndex)def
sectionResizeMode(logicalIndex)def
sectionSize(logicalIndex)def
sectionSizeHint(logicalIndex)def
sectionViewportPosition(logicalIndex)def
sectionsClickable()def
sectionsHidden()def
sectionsMovable()def
sectionsMoved()def
setCascadingSectionResizes(enable)def
setDefaultAlignment(alignment)def
setDefaultSectionSize(size)def
setFirstSectionMovable(movable)def
setHighlightSections(highlight)def
setMaximumSectionSize(size)def
setMinimumSectionSize(size)def
setResizeContentsPrecision(precision)def
setSectionHidden(logicalIndex, hide)def
setSectionResizeMode(logicalIndex, mode)def
setSectionResizeMode(mode)def
setSectionsClickable(clickable)def
setSectionsMovable(movable)def
setSortIndicator(logicalIndex, order)def
setSortIndicatorShown(show)def
setStretchLastSection(stretch)def
showSection(logicalIndex)def
sortIndicatorOrder()def
sortIndicatorSection()def
stretchLastSection()def
stretchSectionCount()def
swapSections(first, second)def
visualIndex(logicalIndex)def
visualIndexAt(position)
Virtual functions¶
def
paintSection(painter, rect, logicalIndex)def
sectionSizeFromContents(logicalIndex)
Slots¶
def
headerDataChanged(orientation, logicalFirst, logicalLast)def
resizeSections()def
sectionsAboutToBeRemoved(parent, logicalFirst, logicalLast)def
sectionsInserted(parent, logicalFirst, logicalLast)def
setOffset(offset)def
setOffsetToLastSection()def
setOffsetToSectionPosition(visualIndex)def
updateSection(logicalIndex)
Signals¶
def
geometriesChanged()def
sectionClicked(logicalIndex)def
sectionCountChanged(oldCount, newCount)def
sectionDoubleClicked(logicalIndex)def
sectionEntered(logicalIndex)def
sectionHandleDoubleClicked(logicalIndex)def
sectionMoved(logicalIndex, oldVisualIndex, newVisualIndex)def
sectionPressed(logicalIndex)def
sectionResized(logicalIndex, oldSize, newSize)def
sortIndicatorChanged(logicalIndex, order)
Detailed Description¶
A
QHeaderViewdisplays the headers used in item views such as theQTableViewandQTreeViewclasses. It takes the place of Qt3’sQHeaderclass previously used for the same purpose, but uses the Qt’s model/view architecture for consistency with the item view classes.The
QHeaderViewclass 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
headerData()function. You can set the data by usingsetHeaderData().Each header has an
orientation()and a number of sections, given by thecount()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()andresizeSection(); they can also be hidden and shown withhideSection()andshowSection().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 withsetSortIndicator(); 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 withsetSectionsClickable(), and has resizing behavior in accordance withsetSectionResizeMode().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, andsectionClicked()as well assectionHandleDoubleClicked()in response to mouse clicks. A header will also emitsectionCountChanged().You can identify a section using the
logicalIndex()andlogicalIndexAt()functions, or by its index position, using thevisualIndex()andvisualIndexAt()functions. The visual index will change if a section is moved, but the logical index will not change.
Appearance¶
QTableWidgetandQTableViewcreate default headers. If you want the headers to be visible, you can usesetVisible().Not all
ItemDataRoles will have an effect on aQHeaderView. If you need to draw other roles, you can subclassQHeaderViewand reimplementpaintEvent().QHeaderViewrespects the following item data roles, unless they are in conflict with the style (which can happen for styles that follow the desktop theme):
TextAlignmentRole,DisplayRole,FontRole,DecorationRole,ForegroundRole, andBackgroundRole.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.
- class PySide2.QtWidgets.QHeaderView(orientation[, parent=None])¶
- param parent:
- param orientation:
Creates a new generic header with the given
orientationandparent.
- PySide2.QtWidgets.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
Description
QHeaderView.Interactive
The user can resize the section. The section can also be resized programmatically using
resizeSection(). The section size defaults todefaultSectionSize. (See alsocascadingSectionResizes.)QHeaderView.Fixed
The user cannot resize the section. The section can only be resized programmatically using
resizeSection(). The section size defaults todefaultSectionSize.QHeaderView.Stretch
QHeaderViewwill automatically resize the section to fill the available space. The size cannot be changed by the user or programmatically.QHeaderView.ResizeToContents
QHeaderViewwill 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
Description
QHeaderView.Custom
Use Fixed instead.
- PySide2.QtWidgets.QHeaderView.cascadingSectionResizes()¶
- Return type:
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
Interactiveas their resize mode.The default value is false.
See also
- PySide2.QtWidgets.QHeaderView.count()¶
- Return type:
int
Returns the number of sections in the header.
See also
- PySide2.QtWidgets.QHeaderView.defaultAlignment()¶
- Return type:
Alignment
This property holds the default alignment of the text in each header section.
- PySide2.QtWidgets.QHeaderView.defaultSectionSize()¶
- Return type:
int
This property holds the default size of the header sections before resizing..
This property only affects sections that have
InteractiveorFixedas their resize mode.By default, the value of this property is style dependent. Thus, when the style changes, this property updates from it. Calling stops the updates, calling will restore default behavior.
See also
- PySide2.QtWidgets.QHeaderView.geometriesChanged()¶
- PySide2.QtWidgets.QHeaderView.headerDataChanged(orientation, logicalFirst, logicalLast)¶
- Parameters:
orientation –
OrientationlogicalFirst – int
logicalLast – int
Updates the changed header sections with the given
orientation, fromlogicalFirsttologicalLastinclusive.
- Return type:
int
Returns the number of sections in the header that has been hidden.
See also
- PySide2.QtWidgets.QHeaderView.hideSection(logicalIndex)¶
- Parameters:
logicalIndex – int
Hides the section specified by
logicalIndex.
- PySide2.QtWidgets.QHeaderView.highlightSections()¶
- Return type:
bool
This property holds whether the sections containing selected items are highlighted.
By default, this property is
false.
- PySide2.QtWidgets.QHeaderView.initStyleOption(option)¶
- Parameters:
option –
PySide2.QtWidgets.QStyleOptionHeader
Initialize
optionwith the values from thisQHeaderView. This method is useful for subclasses when they need aQStyleOptionHeader, but do not want to fill in all the information themselves.See also
- PySide2.QtWidgets.QHeaderView.initialize()¶
- PySide2.QtWidgets.QHeaderView.initializeSections()¶
- PySide2.QtWidgets.QHeaderView.initializeSections(start, end)
- Parameters:
start – int
end – int
- PySide2.QtWidgets.QHeaderView.isFirstSectionMovable()¶
- Return type:
bool
This property holds 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 aftersetSectionsMovable(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
setRootIsDecorated(false) as well.Setting it to true has no effect unless
setSectionsMovable(true) is called as well.See also
- PySide2.QtWidgets.QHeaderView.isSectionHidden(logicalIndex)¶
- Parameters:
logicalIndex – int
- Return type:
bool
Returns
trueif the section specified bylogicalIndexis explicitly hidden from the user; otherwise returnsfalse.
- PySide2.QtWidgets.QHeaderView.isSortIndicatorShown()¶
- Return type:
bool
This property holds whether the sort indicator is shown.
By default, this property is
false.See also
- PySide2.QtWidgets.QHeaderView.length()¶
- Return type:
int
Returns the length along the orientation of the header.
See also
sizeHint()setSectionResizeMode()offset()
- PySide2.QtWidgets.QHeaderView.logicalIndex(visualIndex)¶
- Parameters:
visualIndex – int
- Return type:
int
Returns the for the section at the given
visualIndexposition, or -1 ifvisualIndex< 0 orvisualIndex>=count().Note that the
visualIndexis not affected by hidden sections.See also
- PySide2.QtWidgets.QHeaderView.logicalIndexAt(pos)¶
- Parameters:
pos –
PySide2.QtCore.QPoint- Return type:
int
- PySide2.QtWidgets.QHeaderView.logicalIndexAt(position)
- Parameters:
position – int
- Return type:
int
Returns the section that covers the given
positionin the viewport.See also
- PySide2.QtWidgets.QHeaderView.logicalIndexAt(x, y)
- Parameters:
x – int
y – int
- Return type:
int
Returns the logical index of the section at the given coordinate. If the header is horizontal
xwill be used, otherwiseywill be used to find the logical index.
- PySide2.QtWidgets.QHeaderView.maximumSectionSize()¶
- Return type:
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 modesSee also
- PySide2.QtWidgets.QHeaderView.minimumSectionSize()¶
- Return type:
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,
QHeaderViewwill use the maximum of theglobal strutor thefont metricssize.This property is honored by all
resize modes.See also
- PySide2.QtWidgets.QHeaderView.moveSection(from, to)¶
- Parameters:
from – int
to – int
Moves the section at visual index
fromto occupy visual indexto.See also
- PySide2.QtWidgets.QHeaderView.offset()¶
- Return type:
int
Returns the offset of the header: this is the header’s left-most (or top-most for vertical headers) visible pixel.
See also
- PySide2.QtWidgets.QHeaderView.orientation()¶
- Return type:
Returns the orientation of the header.
See also
Orientation
- PySide2.QtWidgets.QHeaderView.paintSection(painter, rect, logicalIndex)¶
- Parameters:
painter –
PySide2.QtGui.QPainterrect –
PySide2.QtCore.QRectlogicalIndex – int
Paints the section specified by the given
logicalIndex, using the givenpainterandrect.Normally, you do not have to call this function.
- PySide2.QtWidgets.QHeaderView.resetDefaultSectionSize()¶
This property holds the default size of the header sections before resizing..
This property only affects sections that have
InteractiveorFixedas their resize mode.By default, the value of this property is style dependent. Thus, when the style changes, this property updates from it. Calling stops the updates, calling will restore default behavior.
See also
- PySide2.QtWidgets.QHeaderView.resizeContentsPrecision()¶
- Return type:
int
Returns how precise
QHeaderViewwill calculate onResizeToContents.
- PySide2.QtWidgets.QHeaderView.resizeSection(logicalIndex, size)¶
- Parameters:
logicalIndex – int
size – int
Resizes the section specified by
logicalIndextosizemeasured 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 situationhideSectionshould be used instead.See also
- PySide2.QtWidgets.QHeaderView.resizeSections()¶
Resizes the sections according to their size hints. Normally, you do not have to call this function.
- PySide2.QtWidgets.QHeaderView.resizeSections(mode)
- Parameters:
mode –
ResizeMode
Resizes the sections according to the given
mode, ignoring the current resize mode.See also
- PySide2.QtWidgets.QHeaderView.restoreState(state)¶
- Parameters:
state –
PySide2.QtCore.QByteArray- Return type:
bool
Restores the
stateof this header view. This function returnstrueif the state was restored; otherwise returns false.See also
- PySide2.QtWidgets.QHeaderView.saveState()¶
- Return type:
Saves the current state of this header view.
To restore the saved state, pass the return value to
restoreState().See also
- PySide2.QtWidgets.QHeaderView.sectionClicked(logicalIndex)¶
- Parameters:
logicalIndex – int
- PySide2.QtWidgets.QHeaderView.sectionCountChanged(oldCount, newCount)¶
- Parameters:
oldCount – int
newCount – int
- PySide2.QtWidgets.QHeaderView.sectionDoubleClicked(logicalIndex)¶
- Parameters:
logicalIndex – int
- PySide2.QtWidgets.QHeaderView.sectionEntered(logicalIndex)¶
- Parameters:
logicalIndex – int
- PySide2.QtWidgets.QHeaderView.sectionHandleDoubleClicked(logicalIndex)¶
- Parameters:
logicalIndex – int
- PySide2.QtWidgets.QHeaderView.sectionMoved(logicalIndex, oldVisualIndex, newVisualIndex)¶
- Parameters:
logicalIndex – int
oldVisualIndex – int
newVisualIndex – int
- PySide2.QtWidgets.QHeaderView.sectionPosition(logicalIndex)¶
- Parameters:
logicalIndex – int
- Return type:
int
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 withlogicalIndex. The measurement is along the x-axis for horizontal headers and along the y-axis for vertical headers.See also
- PySide2.QtWidgets.QHeaderView.sectionPressed(logicalIndex)¶
- Parameters:
logicalIndex – int
- PySide2.QtWidgets.QHeaderView.sectionResizeMode(logicalIndex)¶
- Parameters:
logicalIndex – int
- Return type:
Returns the resize mode that applies to the section specified by the given
logicalIndex.See also
- PySide2.QtWidgets.QHeaderView.sectionResized(logicalIndex, oldSize, newSize)¶
- Parameters:
logicalIndex – int
oldSize – int
newSize – int
- PySide2.QtWidgets.QHeaderView.sectionSize(logicalIndex)¶
- Parameters:
logicalIndex – int
- Return type:
int
Returns the width (or height for vertical headers) of the given
logicalIndex.
- PySide2.QtWidgets.QHeaderView.sectionSizeFromContents(logicalIndex)¶
- Parameters:
logicalIndex – int
- Return type:
Returns the size of the contents of the section specified by the given
logicalIndex.See also
- PySide2.QtWidgets.QHeaderView.sectionSizeHint(logicalIndex)¶
- Parameters:
logicalIndex – int
- Return type:
int
Returns a suitable size hint for the section specified by
logicalIndex.SizeHintRoleSee also
sizeHint()defaultSectionSize()minimumSectionSize()maximumSectionSize()
- PySide2.QtWidgets.QHeaderView.sectionViewportPosition(logicalIndex)¶
- Parameters:
logicalIndex – int
- Return type:
int
Returns the section viewport position of the given
logicalIndex.If the section is hidden, the return value is undefined.
See also
- PySide2.QtWidgets.QHeaderView.sectionsAboutToBeRemoved(parent, logicalFirst, logicalLast)¶
- Parameters:
parent –
PySide2.QtCore.QModelIndexlogicalFirst – int
logicalLast – int
This slot is called when sections are removed from the
parent.logicalFirstandlogicalLastsignify where the sections were removed.If only one section is removed,
logicalFirstandlogicalLastwill be the same.
- PySide2.QtWidgets.QHeaderView.sectionsClickable()¶
- Return type:
bool
Returns
trueif the header is clickable; otherwise returnsfalse. 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.See also
- PySide2.QtWidgets.QHeaderView.sectionsHidden()¶
- Return type:
bool
Returns
trueif sections in the header has been hidden; otherwise returns false;See also
- PySide2.QtWidgets.QHeaderView.sectionsInserted(parent, logicalFirst, logicalLast)¶
- Parameters:
parent –
PySide2.QtCore.QModelIndexlogicalFirst – int
logicalLast – int
This slot is called when sections are inserted into the
parent.logicalFirstandlogicalLastindices signify where the new sections were inserted.If only one section is inserted,
logicalFirstandlogicalLastwill be the same.
- PySide2.QtWidgets.QHeaderView.sectionsMovable()¶
- Return type:
bool
Returns
trueif 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 inQTableView.See also
- PySide2.QtWidgets.QHeaderView.sectionsMoved()¶
- Return type:
bool
Returns
trueif sections in the header has been moved; otherwise returns false;See also
- PySide2.QtWidgets.QHeaderView.setCascadingSectionResizes(enable)¶
- Parameters:
enable – 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
Interactiveas their resize mode.The default value is false.
See also
- PySide2.QtWidgets.QHeaderView.setDefaultAlignment(alignment)¶
- Parameters:
alignment –
Alignment
This property holds the default alignment of the text in each header section.
- PySide2.QtWidgets.QHeaderView.setDefaultSectionSize(size)¶
- Parameters:
size – int
This property holds the default size of the header sections before resizing..
This property only affects sections that have
InteractiveorFixedas their resize mode.By default, the value of this property is style dependent. Thus, when the style changes, this property updates from it. Calling stops the updates, calling will restore default behavior.
See also
- PySide2.QtWidgets.QHeaderView.setFirstSectionMovable(movable)¶
- Parameters:
movable – bool
This property holds 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 aftersetSectionsMovable(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
setRootIsDecorated(false) as well.Setting it to true has no effect unless
setSectionsMovable(true) is called as well.See also
- PySide2.QtWidgets.QHeaderView.setHighlightSections(highlight)¶
- Parameters:
highlight – bool
This property holds whether the sections containing selected items are highlighted.
By default, this property is
false.
- PySide2.QtWidgets.QHeaderView.setMaximumSectionSize(size)¶
- Parameters:
size – 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 modesSee also
- PySide2.QtWidgets.QHeaderView.setMinimumSectionSize(size)¶
- Parameters:
size – 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,
QHeaderViewwill use the maximum of theglobal strutor thefont metricssize.This property is honored by all
resize modes.See also
- PySide2.QtWidgets.QHeaderView.setOffset(offset)¶
- Parameters:
offset – int
Sets the header’s offset to
offset.
- PySide2.QtWidgets.QHeaderView.setOffsetToLastSection()¶
Sets the offset to make the last section visible.
- PySide2.QtWidgets.QHeaderView.setOffsetToSectionPosition(visualIndex)¶
- Parameters:
visualIndex – int
Sets the offset to the start of the section at the given
visualSectionNumber.visualSectionNumberis the actual visible section when hiddenSections are not considered. That is not always the same asvisualIndex().See also
- PySide2.QtWidgets.QHeaderView.setResizeContentsPrecision(precision)¶
- Parameters:
precision – int
Sets how precise
QHeaderViewshould calculate the size whenResizeToContentsis 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
precisionspecifies 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
sizeHintForColumn(),sizeHintForRow()andsizeHintForColumn(). Reimplementing these functions can make this function not having an effect.See also
resizeContentsPrecision()setSectionResizeMode()resizeSections()sizeHintForColumn()sizeHintForRow()sizeHintForColumn()
- PySide2.QtWidgets.QHeaderView.setSectionHidden(logicalIndex, hide)¶
- Parameters:
logicalIndex – int
hide – bool
If
hideis true the section specified bylogicalIndexis hidden; otherwise the section is shown.See also
- PySide2.QtWidgets.QHeaderView.setSectionResizeMode(mode)¶
- Parameters:
mode –
ResizeMode
Sets the constraints on how the header can be resized to those described by the given
mode.See also
- PySide2.QtWidgets.QHeaderView.setSectionResizeMode(logicalIndex, mode)
- Parameters:
logicalIndex – int
mode –
ResizeMode
Sets the constraints on how the section specified by
logicalIndexin the header can be resized to those described by the givenmode. The logical index should exist at the time this function is called.Note
This setting will be ignored for the last section if the
stretchLastSectionproperty is set to true. This is the default for the horizontal headers provided byQTreeView.
- PySide2.QtWidgets.QHeaderView.setSectionsClickable(clickable)¶
- Parameters:
clickable – bool
If
clickableis true, the header will respond to single clicks.
- PySide2.QtWidgets.QHeaderView.setSectionsMovable(movable)¶
- Parameters:
movable – bool
If
movableis 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 withsetFirstSectionMovable(true).
- PySide2.QtWidgets.QHeaderView.setSortIndicator(logicalIndex, order)¶
- Parameters:
logicalIndex – int
order –
SortOrder
Sets the sort indicator for the section specified by the given
logicalIndexin the direction specified byorder, and removes the sort indicator from any other section that was showing it.logicalIndexmay 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.
- PySide2.QtWidgets.QHeaderView.setSortIndicatorShown(show)¶
- Parameters:
show – bool
This property holds whether the sort indicator is shown.
By default, this property is
false.See also
- PySide2.QtWidgets.QHeaderView.setStretchLastSection(stretch)¶
- Parameters:
stretch – 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
QTreeVieware 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.See also
- PySide2.QtWidgets.QHeaderView.showSection(logicalIndex)¶
- Parameters:
logicalIndex – int
Shows the section specified by
logicalIndex.
- PySide2.QtWidgets.QHeaderView.sortIndicatorChanged(logicalIndex, order)¶
- Parameters:
logicalIndex – int
order –
SortOrder
- PySide2.QtWidgets.QHeaderView.sortIndicatorOrder()¶
- Return type:
Returns the order for the sort indicator. If no section has a sort indicator the return value of this function is undefined.
See also
- PySide2.QtWidgets.QHeaderView.sortIndicatorSection()¶
- Return type:
int
Returns the logical index of the section that has a sort indicator. By default this is section 0.
- PySide2.QtWidgets.QHeaderView.stretchLastSection()¶
- Return type:
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
QTreeVieware 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.See also
- PySide2.QtWidgets.QHeaderView.stretchSectionCount()¶
- Return type:
int
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.
See also
- PySide2.QtWidgets.QHeaderView.swapSections(first, second)¶
- Parameters:
first – int
second – int
Swaps the section at visual index
firstwith the section at visual indexsecond.See also
- PySide2.QtWidgets.QHeaderView.updateSection(logicalIndex)¶
- Parameters:
logicalIndex – int
Updates the section specified by the given
logicalIndex.
- PySide2.QtWidgets.QHeaderView.visualIndex(logicalIndex)¶
- Parameters:
logicalIndex – int
- Return type:
int
Returns the visual index position of the section specified by the given
logicalIndex, or -1 otherwise.Hidden sections still have valid visual indexes.
See also
- PySide2.QtWidgets.QHeaderView.visualIndexAt(position)¶
- Parameters:
position – int
- Return type:
int
Returns the visual index of the section that covers the given
positionin the viewport.See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.