Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QHeaderView Class Reference
[QtGui module]

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

#include <QHeaderView>

Inherits QAbstractItemView.

Public Types

  • enum ResizeMode { Interactive, Stretch, Custom }

Properties

Public Functions

Public Slots

Signals

Protected Functions

Protected Slots

Additional Inherited Members

  • 2 static public members inherited from QFrame
  • 4 static public members inherited from QWidget
  • 4 static public members inherited from QObject

Detailed Description

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

Each header has an orientation() and a number of sections, given by the count() function. Sections can be moved and resized using moveSection() and resizeSection(); they can 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.

A header can be fixed in place, or made movable with setMovable(). It can be made clickable with setClickable(), and has resizing behavior in accordance with setResizeMode().

A header emits sectionMoved() if the user moves a section, sectionResized() if the user resizes a section, and sectionClicked() and sectionHandleDoubleClicked() in response to mouse clicks. A header also emits sectionCountChanged() and sectionAutoResize().

You can identify a section using the section() and sectionAt() functions, or by its index position, using the visualIndex() and visualIndexAt() functions. Note that the visual index can change if a section is moved.

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.

See also Model/View Programming, QListView, QTableView, and QTreeView.


Member Type Documentation

enum QHeaderView::ResizeMode

ConstantValueDescription
QHeaderView::Interactive0Don't automatically change the size (let the user do it manually).
QHeaderView::Stretch1Fill all the available visible space.
QHeaderView::Custom2Don't automatically change the size here, leave it to some other object.

Property Documentation

highlightSections : bool

This property holds whether the sections containing selected items are highlighted.

Access functions:

  • bool highlightSections () const
  • void setHighlightSections ( bool highlight )

showSortIndicator : bool

This property holds whether the sort indicator is shown.

Access functions:

  • bool isSortIndicatorShown () const
  • void setSortIndicatorShown ( bool show )

stretchLastSection : bool

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

Access functions:

  • bool stretchLastSection () const
  • void setStretchLastSection ( bool stretch )

Member Function Documentation

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

Creates a new generic header with the given orientation and parent.

QHeaderView::~QHeaderView ()   [virtual]

Destroys the header.

int QHeaderView::count () const

Returns the number of sections in the header.

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

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

void QHeaderView::hideSection ( int logicalIndex )

Hides the section specified by logicalIndex.

See also showSection() and isSectionHidden().

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

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

Reimplemented from QAbstractItemView.

See also offset().

bool QHeaderView::isClickable () 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.

See also setClickable().

bool QHeaderView::isMovable () const

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

See also setMovable().

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

int QHeaderView::length () const

Returns the length along the orientation of the header.

See also sizeHint().

int QHeaderView::logicalIndex ( int visualIndex ) const

Returns the logicalIndex for the section at the given visualIndex position, or -1 otherwise.

See also visualIndex() and sectionPosition().

int QHeaderView::logicalIndexAt ( int position ) const

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

See also visualIndexAt().

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Returns the logical index of the section at the position given in pos. If the header is horizontal the x-coordinate will be used to find the logical index; otherwise the y-coordinate will be used.

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

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

See also 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.

See also setOffset().

Qt::Orientation QHeaderView::orientation () const

Returns the orientation of the header.

See also Qt::Orientation.

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

Paints the section specified by the given logicalIndex, using the given painter and rect.

You normally would not need to use this function.

ResizeMode QHeaderView::resizeMode ( int logicalIndex ) const

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

See also setResizeMode().

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

Resizes the given logicalIndex to the given size.

void QHeaderView::sectionAutoResize ( int logicalIndex, QHeaderView::ResizeMode mode )   [signal]

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

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

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

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.

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

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

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

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

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

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.

int QHeaderView::sectionPosition ( int logicalIndex ) const

Returns the section position of the given logicalIndex.

See also sectionViewportPosition().

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

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

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

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.

int QHeaderView::sectionSize ( int logicalIndex ) const

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

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

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

int QHeaderView::sectionSizeHint ( int logicalIndex ) const

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

See also sizeHint().

int QHeaderView::sectionViewportPosition ( int logicalIndex ) const

Returns the section viewport position of the given logicalIndex. If the section is hidden the function returns -1.

See also sectionPosition().

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

This slot is called when sections are removed from the parent, logicalFirst and logicalLast signify where the sections are removed from. (logicalFirst and logicalLast will be the same if just one section is removed.)

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

This slot is called when sections are inserted into the parent, logicalFirst and logicalLast indexes signify where the new sections are inserted.

logicalFirst and logicalLast will be the same if just one section is inserted.

bool QHeaderView::sectionsMoved () const

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

See also moveSection().

void QHeaderView::setClickable ( bool clickable )

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

See also isClickable().

void QHeaderView::setMovable ( bool movable )

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

See also isMovable().

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

Sets the header's offset to offset.

See also offset().

void QHeaderView::setResizeMode ( ResizeMode mode )

Sets the constraints on how the header can be resized to those described by the given mode.

See also resizeMode().

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

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the constraints on how the section specified by logicalIndex in the header can be resized to those described by the given mode.

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

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.

See also sortIndicatorSection() and sortIndicatorOrder().

void QHeaderView::showSection ( int logicalIndex )

Shows the section specified by logicalIndex.

See also hideSection() and isSectionHidden().

QSize QHeaderView::sizeHint () const   [virtual]

Returns a suitable size hint for this header.

Reimplemented from QWidget.

See also sectionSizeHint().

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

See also setSortIndicator(), sortIndicatorOrder(), and setSortIndicatorShown().

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

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

Reimplemented from QAbstractItemView.

See also offset().

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

int QHeaderView::visualIndexAt ( int position ) const

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

See also logicalIndexAt().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 64
  2. Apercevoir la troisième dimension ou l'utilisation multithreadée d'OpenGL dans Qt, un article des Qt Quarterly traduit par Guillaume Belz 0
  3. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  4. BlackBerry 10 : premières images du prochain OS de RIM qui devrait intégrer des widgets et des tuiles inspirées de Windows Phone 0
  5. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  6. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil déclaratif et extensible pour la compilation de projets Qt 17
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le blog Digia au hasard

Logo

Créer des applications avec un style Metro avec Qt, exemples en QML et C++, un article de Digia Qt traduit par Thibaut Cuvelier

Le blog Digia est l'endroit privilégié pour la communication sur l'édition commerciale de Qt, où des réponses publiques sont apportées aux questions les plus posées au support. Lire l'article.

Communauté

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la rédaction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 4.0
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web