IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QHeaderView Class

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QHeaderView Class▲

  • Header: QHeaderView

  • qmake: QT += widgets

  • Inherits: https://

  • Group: QHeaderView is part of model-view

Detailed Description▲

A https:// displays the headers used in item views such as the https:// and https:// 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 https:// class is one of the https:// and is part of Qt's https://.

The header gets the data for each section from the model using the https://() function. You can set the data by using https://().

Each header has an https://() and a number of sections, given by the https://() 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 https://() and https://(); they can also be hidden and shown with https://() and https://().

Each section of a header is described by a section ID, specified by its section(), and can be located at a particular https://() in the header. A section can have a sort indicator set with https://(); 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 https://(). It can be made clickable with https://(), and has resizing behavior in accordance with https://().

Double-clicking on a header to resize a section only applies for visible rows.

A header will emit https://() if the user moves a section, https://() if the user resizes a section, and https://() as well as https://() in response to mouse clicks. A header will also emit https://().

You can identify a section using the https://() and https://() functions, or by its index position, using the https://() and https://() functions. The visual index will change if a section is moved, but the logical index will not change.

Appearance▲

https:// and https:// create default headers. If you want the headers to be visible, you can use https://().

Not all https://s will have an effect on a https://. If you need to draw other roles, you can subclass https:// and reimplement https://(). https:// respects the following item data roles, unless they are in conflict with the style (which can happen for styles that follow the desktop theme):

https://, https://, https://, https://, https://, and https://.

Each header renders the data for each section itself, and does not rely on a delegate. As a result, calling a header's https://() function will have no effect.

See Also▲

See also https://, https://, https://, https://

Member Type Documentation▲

 

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 https://().

Constant

Value

Description

https://::Interactive

0

The user can resize the section. The section can also be resized programmatically using https://(). The section size defaults to https://. (See also https://.)

https://::Fixed

2

The user cannot resize the section. The section can only be resized programmatically using https://(). The section size defaults to https://.

https://::Stretch

1

https:// will automatically resize the section to fill the available space. The size cannot be changed by the user or programmatically.

https://::ResizeToContents

3

https:// 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

https://::Custom

Fixed

Use Fixed instead.

See Also▲

See also https://, setSectionResizeMode(), https://, https://

Property Documentation▲

 

[since 4.2] 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 https:// as their resize mode.

The default value is false.

This property was introduced in Qt 4.2.

Access functions:

  • bool cascadingSectionResizes() const

  • void setCascadingSectionResizes(bool enable)

See Also▲

See also https://()

[since 4.1] defaultAlignment : Qt::Alignment▲

This property holds the default alignment of the text in each header section

This property was introduced in Qt 4.1.

Access functions:

  • defaultAlignment() const

  • void setDefaultAlignment( alignment)

defaultSectionSize : int▲

This property holds the default size of the header sections before resizing.

This property only affects sections that have https:// or https:// 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.

Access functions:

  • int defaultSectionSize() const

  • void setDefaultSectionSize(int size)

  • void resetDefaultSectionSize()

See Also▲

See also https://(), https://

[since 5.11] firstSectionMovable : 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 https://, the first column holds the tree structure and is therefore non-movable by default, even after https://(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 https://(false) as well.

Setting it to true has no effect unless https://(true) is called as well.

This property was introduced in Qt 5.11.

Access functions:

  • bool isFirstSectionMovable() const

  • void setFirstSectionMovable(bool movable)

See Also▲

See also https://()

highlightSections : bool▲

This property holds whether the sections containing selected items are highlighted

By default, this property is false.

Access functions:

  • bool highlightSections() const

  • void setHighlightSections(bool highlight)

[since 5.2] 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 https://

This property was introduced in Qt 5.2.

Access functions:

  • int maximumSectionSize() const

  • void setMaximumSectionSize(int size)

See Also▲

See also https://(), https://

[since 4.2] 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, https:// will use the maximum of the https:// or the https:// size.

This property is honored by all https://.

This property was introduced in Qt 4.2.

Access functions:

  • int minimumSectionSize() const

  • void setMinimumSectionSize(int size)

See Also▲

See also https://(), https://

showSortIndicator : bool▲

This property holds whether the sort indicator is shown

By default, this property is false.

Access functions:

  • bool isSortIndicatorShown() const

  • void setSortIndicatorShown(bool show)

See Also▲

See also https://()

stretchLastSection : bool▲

This property holds whether the last visible section in the header takes up all the available space

The default value is false.

The horizontal headers provided by https:// 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.

Access functions:

  • bool stretchLastSection() const

  • void setStretchLastSection(bool stretch)

See Also▲

See also https://()

Member Function Documentation▲

 

[explicit] QHeaderView::QHeaderView(Qt::Orientation orientation, QWidget *parent = 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.

See Also▲

See also https://(), https://()

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

Reimplements: https://.

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

Reimplements: https://.

[since 4.2] void QHeaderView::geometriesChanged()▲

This signal is emitted when the header's geometries have changed.

This function was introduced in Qt 4.2.

void QHeaderView::headerDataChanged(Qt::Orientation orientation, int logicalFirst, int logicalLast)▲

Updates the changed header sections with the given orientation, from logicalFirst to logicalLast inclusive.

[since 4.1] int QHeaderView::hiddenSectionCount() const▲

Returns the number of sections in the header that has been hidden.

This function was introduced in Qt 4.1.

See Also▲

See also https://(), https://()

void QHeaderView::hideSection(int logicalIndex)▲

Hides the section specified by logicalIndex.

See Also▲

See also https://(), https://(), https://(), https://()

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

Reimplements: https://.

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

See Also▲

See also https://()

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

Initialize option with the values from this https://. This method is useful for subclasses when they need a https://, but do not want to fill in all the information themselves.

See Also▲

See also https://()

bool QHeaderView::isSectionHidden(int logicalIndex) const▲

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

See Also▲

See also https://(), https://(), https://(), https://()

int QHeaderView::length() const▲

Returns the length along the orientation of the header.

See Also▲

See also https://(), https://(), https://()

int QHeaderView::logicalIndex(int visualIndex) const▲

Returns the logicalIndex for the section at the given visualIndex position, or -1 if https:// < 0 or https:// >= https://().

Note that the https:// is not affected by hidden sections.

See Also▲

See also https://(), https://()

int QHeaderView::logicalIndexAt(int position) const▲

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

See Also▲

See also https://(), https://()

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.

See Also▲

See also https://()

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

Reimplements: https://.

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

Reimplements: https://.

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

Reimplements: https://.

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

Reimplements: https://.

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

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

See Also▲

See also https://()

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.

See Also▲

See also https://()

Qt::Orientation QHeaderView::orientation() const▲

Returns the orientation of the header.

See Also▲

See also https://

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

Reimplements: https://.

[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.

[override virtual] void QHeaderView::reset()▲

Reimplements: https://.

[since 5.2] int QHeaderView::resizeContentsPrecision() const▲

Returns how precise https:// will calculate on https://.

This function was introduced in Qt 5.2.

See Also▲

See also https://(), https://()

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 https:// should be used instead.

See Also▲

See also https://(), https://, sectionSize(), https://()

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

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

See Also▲

See also https://, sectionResized()

[protected] void QHeaderView::resizeSections()▲

Resizes the sections according to their size hints. Normally, you do not have to call this function.

[since 4.3] 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.

See Also▲

See also https://()

[since 4.3] QByteArray QHeaderView::saveState() const▲

Saves the current state of this header view.

To restore the saved state, pass the return value to https://().

This function was introduced in Qt 4.3.

See Also▲

See also https://()

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 https:// signal will also be emitted.

See Also▲

See also https://(), https://()

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.

See Also▲

See also https://(), https://(), https://()

void QHeaderView::sectionDoubleClicked(int logicalIndex)▲

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

See Also▲

See also https://()

[since 4.3] 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.

See Also▲

See also https://(), https://()

void QHeaderView::sectionHandleDoubleClicked(int logicalIndex)▲

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

See Also▲

See also https://()

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.

See Also▲

See also https://()

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.

See Also▲

See also https://()

void QHeaderView::sectionPressed(int logicalIndex)▲

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

See Also▲

See also https://()

[since 5.0] QHeaderView::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.

See Also▲

See also https://()

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.

See Also▲

See also https://()

int QHeaderView::sectionSize(int logicalIndex) const▲

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

See Also▲

See also https://(), https://(), https://()

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

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

See Also▲

See also https://()

int QHeaderView::sectionSizeHint(int logicalIndex) const▲

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

https://

See Also▲

See also https://(), https://(), https://(), https://()

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.

See Also▲

See also https://(), https://()

[protected] 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.

[since 5.0] 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.

See Also▲

See also https://()

[since 4.1] 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.

See Also▲

See also https://()

[protected] 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.

[since 5.0] bool QHeaderView::sectionsMovable() const▲

Returns true if the header can be moved by the user; otherwise returns false.

By default, sections are movable in https:// (except for the first one), and not movable in https://.

This function was introduced in Qt 5.0.

See Also▲

See also https://()

bool QHeaderView::sectionsMoved() const▲

Returns true if sections in the header has been moved; otherwise returns false;

See Also▲

See also https://()

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

Reimplements: https://.

void QHeaderView::setOffset(int offset)▲

Sets the header's offset to offset.

See Also▲

See also https://(), https://()

[since 4.2] void QHeaderView::setOffsetToLastSection()▲

Sets the offset to make the last section visible.

This function was introduced in Qt 4.2.

See Also▲

See also https://(), https://(), https://()

[since 4.2] 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 https://().

This function was introduced in Qt 4.2.

See Also▲

See also https://(), https://()

[since 5.2] void QHeaderView::setResizeContentsPrecision(int precision)▲

Sets how precise https:// should calculate the size when https:// 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 https://(), https://() and https://(). Reimplementing these functions can make this function not having an effect.

This function was introduced in Qt 5.2.

See Also▲

See also https://(), https://(), https://(), https://(), https://(), https://()

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

If hide is true the section specified by logicalIndex is hidden; otherwise the section is shown.

See Also▲

See also https://(), https://()

[since 5.0] void QHeaderView::setSectionResizeMode(QHeaderView::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.

See Also▲

See also https://(), https://, length(), https://()

[since 5.0] void QHeaderView::setSectionResizeMode(int logicalIndex, QHeaderView::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.

This setting will be ignored for the last section if the https:// property is set to true. This is the default for the horizontal headers provided by https://.

This function was introduced in Qt 5.0.

See Also▲

See also https://(), https://()

[since 5.0] void QHeaderView::setSectionsClickable(bool clickable)▲

If clickable is true, the header will respond to single clicks.

This function was introduced in Qt 5.0.

See Also▲

See also https://(), https://(), https://(), https://()

[since 5.0] void QHeaderView::setSectionsMovable(bool movable)▲

If movable is true, the header sections may be moved by the user; otherwise they are fixed in place.

When used in combination with https://, the first column is not movable (since it contains the tree structure), by default. You can make it movable with https://(true).

This function was introduced in Qt 5.0.

See Also▲

See also https://(), https://(), https://()

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

Reimplements: https://.

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.

See Also▲

See also https://(), https://()

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

Reimplements an access function for property: https://.

void QHeaderView::showSection(int logicalIndex)▲

Shows the section specified by logicalIndex.

See Also▲

See also https://(), https://(), https://(), https://()

[override virtual] QSize QHeaderView::sizeHint() const▲

Reimplements: https://.

Returns a suitable size hint for this header.

See Also▲

See also https://()

[since 4.3] 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.

See Also▲

See also https://()

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.

See Also▲

See also https://(), https://()

int QHeaderView::sortIndicatorSection() const▲

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

See Also▲

See also https://(), https://(), https://()

[since 4.1] 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.

See Also▲

See also https://, resizeMode()

[since 4.2] 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.

See Also▲

See also https://()

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

Reimplements: https://.

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

See Also▲

See also https://()

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

Reimplements: https://.

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.

See Also▲

See also https://()

int QHeaderView::visualIndexAt(int position) const▲

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

See Also▲

See also https://()

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+   

Ce document est disponible sous la licence https:// telle que publiée par la Free Software Foundation.