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  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

Q3Header Class Reference

The Q3Header class provides a header row or column, e.g. for tables and listviews. More...

 #include <Q3Header>

This class is part of the Qt 3 support library. It is provided to keep old source code working. We strongly advise against using it in new code. See Porting to Qt 4 for more information.

Inherits: QWidget.

Properties

  • 58 properties inherited from QWidget
  • 1 property inherited from QObject

Public Functions

Q3Header ( QWidget * parent = 0, const char * name = 0 )
Q3Header ( int n, QWidget * parent = 0, const char * name = 0 )
~Q3Header ()
int addLabel ( const QString & s, int size = -1 )
int addLabel ( const QIcon & icon, const QString & s, int size = -1 )
void adjustHeaderSize ()
int cellAt ( int pos ) const
int cellPos ( int i ) const
int cellSize ( int i ) const
int count () const
int headerWidth () const
QIcon * iconSet ( int section ) const
bool isClickEnabled ( int section = -1 ) const
bool isMovingEnabled () const
bool isResizeEnabled ( int section = -1 ) const
bool isStretchEnabled () const
bool isStretchEnabled ( int section ) const
QString label ( int section ) const
int mapToActual ( int l ) const
int mapToIndex ( int section ) const
int mapToLogical ( int a ) const
int mapToSection ( int index ) const
virtual void moveCell ( int fromIdx, int toIdx )
void moveSection ( int section, int toIndex )
int offset () const
Qt::Orientation orientation () const
void removeLabel ( int section )
void resizeSection ( int section, int s )
int sectionAt ( int pos ) const
int sectionPos ( int section ) const
QRect sectionRect ( int section ) const
int sectionSize ( int section ) const
virtual void setCellSize ( int section, int s )
virtual void setClickEnabled ( bool enable, int section = -1 )
virtual void setLabel ( int section, const QString & s, int size = -1 )
virtual void setLabel ( int section, const QIcon & icon, const QString & s, int size = -1 )
virtual void setMovingEnabled ( bool )
virtual void setOrientation ( Qt::Orientation )
virtual void setResizeEnabled ( bool enable, int section = -1 )
void setSortIndicator ( int section, Qt::SortOrder order )
void setSortIndicator ( int section, bool ascending = true )
virtual void setStretchEnabled ( bool b, int section )
void setStretchEnabled ( bool b )
virtual void setTracking ( bool enable )
Qt::SortOrder sortIndicatorOrder () const
int sortIndicatorSection () const
bool tracking () const

Reimplemented Public Functions

virtual QSize sizeHint () const
  • 217 public functions inherited from QWidget
  • 29 public functions inherited from QObject
  • 13 public functions inherited from QPaintDevice

Public Slots

virtual void setOffset ( int pos )
  • 19 public slots inherited from QWidget
  • 1 public slot inherited from QObject

Signals

void clicked ( int section )
void indexChange ( int section, int fromIndex, int toIndex )
void moved ( int fromIndex, int toIndex )
void pressed ( int section )
void released ( int section )
void sectionClicked ( int index )
void sectionHandleDoubleClicked ( int section )
void sizeChange ( int section, int oldSize, int newSize )

Protected Functions

virtual void paintSection ( QPainter * p, int index, const QRect & fr )
virtual void paintSectionLabel ( QPainter * p, int index, const QRect & fr )
QRect sRect ( int index )

Reimplemented Protected Functions

virtual void changeEvent ( QEvent * ev )
virtual void keyPressEvent ( QKeyEvent * e )
virtual void keyReleaseEvent ( QKeyEvent * e )
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 resizeEvent ( QResizeEvent * e )
virtual void showEvent ( QShowEvent * e )
  • 37 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject
  • 1 protected function inherited from QPaintDevice

Additional Inherited Members

  • 4 static public members inherited from QWidget
  • 5 static public members inherited from QObject
  • 1 protected slot inherited from QWidget

Detailed Description

The Q3Header class provides a header row or column, e.g. for tables and listviews.

This class provides a header, e.g. a vertical header to display row labels, or a horizontal header to display column labels. It is used by Q3Table and Q3ListView for example.

A header is composed of one or more sections, each of which can display a text label and an icon. A sort indicator (an arrow) can also be displayed using setSortIndicator().

Sections are added with addLabel() and removed with removeLabel(). The label and icon are set in addLabel() and can be changed later with setLabel(). Use count() to retrieve the number of sections in the header.

The orientation of the header is set with setOrientation(). If setStretchEnabled() is true, the sections will expand to take up the full width (height for vertical headers) of the header. The user can resize the sections manually if setResizeEnabled() is true. Call adjustHeaderSize() to have the sections resize to occupy the full width (or height).

A section can be moved with moveSection(). If setMovingEnabled() is true (the default)the user may drag a section from one position to another. If a section is moved, the index positions at which sections were added (with addLabel()), may not be the same after the move. You don't have to worry about this in practice because the Q3Header API works in terms of section numbers, so it doesn't matter where a particular section has been moved to.

If you want the current index position of a section call mapToIndex() giving it the section number. (This is the number returned by the addLabel() call which created the section.) If you want to get the section number of a section at a particular index position call mapToSection() giving it the index number.

Here's an example to clarify mapToSection() and mapToIndex():

Index positions
0123
Original section ordering
Sect 0Sect 1Sect 2Sect 3
Ordering after the user moves a section
Sect 0Sect 2Sect 3Sect 1
kmapToSection(k)mapToIndex(k)
000
123
231
312

In the example above, if we wanted to find out which section is at index position 3 we'd call mapToSection(3) and get a section number of 1 since section 1 was moved. Similarly, if we wanted to know which index position section 2 occupied we'd call mapToIndex(2) and get an index of 1.

Q3Header provides the clicked(), pressed() and released() signals. If the user changes the size of a section, the sizeChange() signal is emitted. If you want to have a sizeChange() signal emitted continuously whilst the user is resizing (rather than just after the resizing is finished), use setTracking(). If the user moves a section the indexChange() signal is emitted.

See also Q3ListView and Q3Table.

Property Documentation

count : const int

This property holds the number of sections in the header.

Access functions:

int count () const

moving : bool

This property holds whether the header sections can be moved.

If this property is true (the default) the user can move sections. If the user moves a section the indexChange() signal is emitted.

Access functions:

bool isMovingEnabled () const
virtual void setMovingEnabled ( bool )

See also setClickEnabled() and setResizeEnabled().

offset : int

This property holds the header's left-most (or top-most) visible pixel.

Setting this property will scroll the header so that offset becomes the left-most (or top-most for vertical headers) visible pixel.

Access functions:

int offset () const
virtual void setOffset ( int pos )

orientation : Qt::Orientation

This property holds the header's orientation.

The orientation is either Qt::Vertical or Qt::Horizontal (the default).

Call setOrientation() before adding labels if you don't provide a size parameter otherwise the sizes will be incorrect.

Access functions:

Qt::Orientation orientation () const
virtual void setOrientation ( Qt::Orientation )

stretching : bool

This property holds whether the header sections always take up the full width (or height) of the header.

Access functions:

bool isStretchEnabled () const
bool isStretchEnabled ( int section ) const
virtual void setStretchEnabled ( bool b, int section )
void setStretchEnabled ( bool b )

tracking : bool

This property holds whether the sizeChange() signal is emitted continuously.

If tracking is on, the sizeChange() signal is emitted continuously while the mouse is moved (i.e. when the header is resized), otherwise it is only emitted when the mouse button is released at the end of resizing.

Tracking defaults to false.

Access functions:

bool tracking () const
virtual void setTracking ( bool enable )

Member Function Documentation

Q3Header::Q3Header ( QWidget * parent = 0, const char * name = 0 )

Constructs a horizontal header called name, with parent parent.

Q3Header::Q3Header ( int n, QWidget * parent = 0, const char * name = 0 )

Constructs a horizontal header called name, with n sections and parent parent.

Q3Header::~Q3Header ()

Destroys the header and all its sections.

int Q3Header::addLabel ( const QString & s, int size = -1 )

Adds a new section with label text s. Returns the index position where the section was added (at the right for horizontal headers, at the bottom for vertical headers). The section's width is set to size. If size < 0, an appropriate size for the text s is chosen.

int Q3Header::addLabel ( const QIcon & icon, const QString & s, int size = -1 )

This is an overloaded function.

Adds a new section with icon icon and label text s. Returns the index position where the section was added (at the right for horizontal headers, at the bottom for vertical headers). The section's width is set to size, unless size is negative in which case the size is calculated taking account of the size of the text.

void Q3Header::adjustHeaderSize ()

Adjusts the size of the sections to fit the size of the header as completely as possible. Only sections for which isStretchEnabled() is true will be resized.

int Q3Header::cellAt ( int pos ) const

Use sectionAt() instead.

Returns the index at which the section is displayed, which contains pos in widget coordinates, or -1 if pos is outside the header sections.

int Q3Header::cellPos ( int i ) const

Use sectionPos() instead.

Returns the position in pixels of the section that is displayed at the index i. The position is measured from the start of the header.

int Q3Header::cellSize ( int i ) const

Use sectionSize() instead.

Returns the size in pixels of the section that is displayed at the index i.

See also setCellSize().

void Q3Header::changeEvent ( QEvent * ev ) [virtual protected]

Reimplemented from QWidget::changeEvent().

void Q3Header::clicked ( int section ) [signal]

If isClickEnabled() is true, this signal is emitted when the user clicks section section.

See also pressed() and released().

int Q3Header::headerWidth () const

Returns the total width of all the header columns.

QIcon * Q3Header::iconSet ( int section ) const

Returns the icon set for section section. If the section does not exist, 0 is returned.

void Q3Header::indexChange ( int section, int fromIndex, int toIndex ) [signal]

This signal is emitted when the user moves section section from index position fromIndex, to index position toIndex.

bool Q3Header::isClickEnabled ( int section = -1 ) const

Returns true if section section is clickable; otherwise returns false.

If section is out of range (negative or larger than count() - 1): returns true if all sections are clickable; otherwise returns false.

See also setClickEnabled().

bool Q3Header::isResizeEnabled ( int section = -1 ) const

Returns true if section section is resizeable; otherwise returns false.

If section is -1 then this function applies to all sections, i.e. returns true if all sections are resizeable; otherwise returns false.

See also setResizeEnabled().

void Q3Header::keyPressEvent ( QKeyEvent * e ) [virtual protected]

Reimplemented from QWidget::keyPressEvent().

void Q3Header::keyReleaseEvent ( QKeyEvent * e ) [virtual protected]

Reimplemented from QWidget::keyReleaseEvent().

QString Q3Header::label ( int section ) const

Returns the text for section section. If the section does not exist, returns an empty string.

See also setLabel().

int Q3Header::mapToActual ( int l ) const

Use mapToIndex() instead.

Translates from logical index l to actual index (index at which the section l is displayed) . Returns -1 if l is outside the legal range.

See also mapToLogical().

int Q3Header::mapToIndex ( int section ) const

Returns the index position at which section section is displayed.

int Q3Header::mapToLogical ( int a ) const

Use mapToSection() instead.

Translates from actual index a (index at which the section is displayed) to logical index of the section. Returns -1 if a is outside the legal range.

See also mapToActual().

int Q3Header::mapToSection ( int index ) const

Returns the number of the section that is displayed at index position index.

void Q3Header::mouseDoubleClickEvent ( QMouseEvent * e ) [virtual protected]

Reimplemented from QWidget::mouseDoubleClickEvent().

void Q3Header::mouseMoveEvent ( QMouseEvent * e ) [virtual protected]

Reimplemented from QWidget::mouseMoveEvent().

void Q3Header::mousePressEvent ( QMouseEvent * e ) [virtual protected]

Reimplemented from QWidget::mousePressEvent().

void Q3Header::mouseReleaseEvent ( QMouseEvent * e ) [virtual protected]

Reimplemented from QWidget::mouseReleaseEvent().

void Q3Header::moveCell ( int fromIdx, int toIdx ) [virtual]

Use moveSection() instead.

Moves the section that is currently displayed at index fromIdx to index toIdx.

void Q3Header::moveSection ( int section, int toIndex )

Moves section section to index position toIndex.

void Q3Header::moved ( int fromIndex, int toIndex ) [signal]

Use indexChange() instead.

This signal is emitted when the user has moved the section which is displayed at the index fromIndex to the index toIndex.

void Q3Header::paintEvent ( QPaintEvent * e ) [virtual protected]

Reimplemented from QWidget::paintEvent().

void Q3Header::paintSection ( QPainter * p, int index, const QRect & fr ) [virtual protected]

Paints the section at position index, inside rectangle fr (which uses widget coordinates) using painter p.

Calls paintSectionLabel().

void Q3Header::paintSectionLabel ( QPainter * p, int index, const QRect & fr ) [virtual protected]

Paints the label of the section at position index, inside rectangle fr (which uses widget coordinates) using painter p.

Called by paintSection()

void Q3Header::pressed ( int section ) [signal]

This signal is emitted when the user presses section section down.

See also released().

void Q3Header::released ( int section ) [signal]

This signal is emitted when section section is released.

See also pressed().

void Q3Header::removeLabel ( int section )

Removes section section. If the section does not exist, nothing happens.

void Q3Header::resizeEvent ( QResizeEvent * e ) [virtual protected]

Reimplemented from QWidget::resizeEvent().

void Q3Header::resizeSection ( int section, int s )

Resizes section section to s pixels wide (or high).

QRect Q3Header::sRect ( int index ) [protected]

Returns the rectangle covered by the section at index index.

int Q3Header::sectionAt ( int pos ) const

Returns the index of the section which contains the position pos given in pixels from the left (or top).

See also offset().

void Q3Header::sectionClicked ( int index ) [signal]

Use clicked() instead.

This signal is emitted when a part of the header is clicked. index is the index at which the section is displayed.

In a list view this signal would typically be connected to a slot that sorts the specified column (or row).

void Q3Header::sectionHandleDoubleClicked ( int section ) [signal]

This signal is emitted when the user doubleclicks on the edge (handle) of section section.

int Q3Header::sectionPos ( int section ) const

Returns the position (in pixels) at which the section starts.

See also offset().

QRect Q3Header::sectionRect ( int section ) const

Returns the rectangle covered by section section.

int Q3Header::sectionSize ( int section ) const

Returns the width (or height) of the section in pixels.

void Q3Header::setCellSize ( int section, int s ) [virtual]

Use resizeSection() instead.

Sets the size of the section section to s pixels.

Warning: does not repaint or send out signals

See also cellSize().

void Q3Header::setClickEnabled ( bool enable, int section = -1 ) [virtual]

If enable is true, any clicks on section section will result in clicked() signals being emitted; otherwise the section will ignore clicks.

If section is -1 (the default) then the enable value is set for all existing sections and will be applied to any new sections that are added.

See also isClickEnabled(), setMovingEnabled(), and setResizeEnabled().

void Q3Header::setLabel ( int section, const QString & s, int size = -1 ) [virtual]

Sets the text of section section to s. The section's width is set to size if size >= 0; otherwise it is left unchanged. Any icon set that has been set for this section remains unchanged.

If the section does not exist, nothing happens.

See also label().

void Q3Header::setLabel ( int section, const QIcon & icon, const QString & s, int size = -1 ) [virtual]

This is an overloaded function.

Sets the icon for section section to icon and the text to s. The section's width is set to size if size >= 0; otherwise it is left unchanged.

If the section does not exist, nothing happens.

void Q3Header::setResizeEnabled ( bool enable, int section = -1 ) [virtual]

If enable is true the user may resize section section; otherwise the section may not be manually resized.

If section is negative (the default) then the enable value is set for all existing sections and will be applied to any new sections that are added. Example:

 // Allow resizing of all current and future sections
 header->setResizeEnabled(true);
 // Disable resizing of section 3, (the fourth section added)
 header->setResizeEnabled(false, 3);

If the user resizes a section, a sizeChange() signal is emitted.

See also isResizeEnabled(), setMovingEnabled(), setClickEnabled(), and setTracking().

void Q3Header::setSortIndicator ( int section, Qt::SortOrder order )

Sets a sort indicator onto the specified section. The indicator's order is either Ascending or Descending.

Only one section can show a sort indicator at any one time. If you don't want any section to show a sort indicator pass a section number of -1.

See also sortIndicatorSection() and sortIndicatorOrder().

void Q3Header::setSortIndicator ( int section, bool ascending = true )

This is an overloaded function.

Sets the sort indicator to ascending. Use the other overload instead.

void Q3Header::showEvent ( QShowEvent * e ) [virtual protected]

Reimplemented from QWidget::showEvent().

void Q3Header::sizeChange ( int section, int oldSize, int newSize ) [signal]

This signal is emitted when the user has changed the size of a section from oldSize to newSize. This signal is typically connected to a slot that repaints the table or list that contains the header.

QSize Q3Header::sizeHint () const [virtual]

Reimplemented from QWidget::sizeHint().

Qt::SortOrder Q3Header::sortIndicatorOrder () const

Returns the implied sort order of the Q3Headers sort indicator.

See also setSortIndicator() and sortIndicatorSection().

int Q3Header::sortIndicatorSection () const

Returns the section showing the sort indicator or -1 if there is no sort indicator.

See also setSortIndicator() and sortIndicatorOrder().

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année
  1. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 73
  2. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 27
  3. Une nouvelle ère d'IHM 3D pour les automobiles, un concept proposé par Digia et implémenté avec Qt 3
  4. Qt Creator 2.5 est sorti en beta, l'EDI supporte maintenant plus de fonctionnalités de C++11 2
  5. Vingt sociétés montrent leurs décodeurs basés sur Qt au IPTV World Forum, en en exploitant diverses facettes (déclaratif, Web, widgets) 0
  6. PySide devient un add-on Qt et rejoint le Qt Project et le modèle d'open gouvernance 1
  7. Thread travailleur avec Qt en utilisant les signaux et les slots, un article de Christophe Dumez traduit par Thibaut Cuvelier 1
  1. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 102
  2. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 53
  3. «Le projet de loi des droits du développeur» : quelles conditions doivent remplir les entreprises pour que le développeur puisse réussir ? 73
  4. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 27
  5. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 11
Page suivante
  1. Linus Torvalds : le "C++ est un langage horrible", en justifiant le choix du C pour le système de gestion de version Git 100
  2. Comment prendre en compte l'utilisateur dans vos applications ? Pour un développeur, « 90 % des utilisateurs sont des idiots » 229
  3. Quel est LE livre que tout développeur doit lire absolument ? Celui qui vous a le plus marqué et inspiré 96
  4. Apple cède et s'engage à payer des droits à Nokia, le conflit des brevets entre les deux firmes s'achève 158
  5. Nokia porte à nouveau plainte contre Apple pour violation de sept nouveaux brevets 158
  6. Quel est le code dont vous êtes le plus fier ? Pourquoi l'avez-vous écrit ? Et pourquoi vous a-t-il donné autant de satisfaction ? 83
  7. « Quelque chose ne va vraiment pas avec les développeurs "modernes" », un développeur à "l'ancienne" critique la multiplication des bibliothèques 101
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.7
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