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  · 

QTabBar Class Reference
[QtGui module]

The QTabBar class provides a tab bar, e.g. for use in tabbed dialogs. More...

#include <QTabBar>

Inherits QWidget.

Public Types

  • enum Shape { RoundedNorth, RoundedSouth, RoundedWest, RoundedEast, ..., TriangularEast }

Properties

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

Public Functions

  • 184 public functions inherited from QWidget
  • 28 public functions inherited from QObject
  • 10 public functions inherited from QPaintDevice

Public Slots

  • 17 public slots inherited from QWidget
  • 1 public slot inherited from QObject

Signals

Protected Functions

  • 39 protected functions inherited from QWidget
  • 7 protected functions inherited from QObject

Additional Inherited Members

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

Detailed Description

The QTabBar class provides a tab bar, e.g. for use in tabbed dialogs.

QTabBar is straightforward to use; it draws the tabs using one of the predefined shapes, and emits a signal when a tab is selected. It can be subclassed to tailor the look and feel. Qt also provides a ready-made QTabWidget.

Each tab has a tabText(), an optional tabIcon(), an optional tabToolTip(), and optional tabData(). The tabs's attributes can be changed with setTabText(), setTabIcon(), setTabToolTip(), and setTabData(). Each tabs can be enabled or disabled individually with setTabEnabled().

Tabs are added using addTab(), or inserted at particular positions using insertTab(). The total number of tabs is given by count(). Tabs can be removed from the tab bar with removeTab(). Combining removeTab() and insertTab() allows you to move tabs to different positions.

The shape property defines the tabs' appearance. The choice of shape is a matter of taste, although tab dialogs (for preferences and similar) invariably use RoundedNorth. Tab controls in windows other than dialogs almost always use either RoundedSouth or TriangularSouth. Many spreadsheets and other tab controls in which all the pages are essentially similar use TriangularSouth, whereas RoundedSouth is used mostly when the pages are different (e.g. a multi-page tool palette). The default in QTabBar is RoundedNorth.

The most important part of QTabBar's API is the currentChanged() signal. This is emitted whenever the current tab changes (even at startup, when the current tab changes from 'none'). There is also a slot, setCurrentIndex(), which can be used to select a tab programmatically. The function currentIndex() returns the index of the current tab, count holds the number of tabs.

QTabBar creates automatic mnemonic keys in the manner of QAbstractButton; e.g. if a tab's label is "&Graphics", Alt+G becomes a shortcut key for switching to that tab.

The following virtual functions may need to be reimplemented in order to tailor the look and feel or store extra data with each tab:

For subclasses, you might also need the tabRect() functions which returns the visual geometry of a single tab.

Screenshot in Motif style Screenshot in Windows style


Member Type Documentation

enum QTabBar::Shape

This enum type lists the built-in shapes supported by QTabBar. Treat these as hints as some styles may not render some of the shapes. However, position should be honored.

ConstantValueDescription
QTabBar::RoundedNorth0The normal rounded look above the pages
QTabBar::RoundedSouth1The normal rounded look below the pages
QTabBar::RoundedWest2The normal rounded look on the left side of the pages
QTabBar::RoundedEast3The normal rounded look on the right side the pages
QTabBar::TriangularNorth4Triangular tabs above the pages.
QTabBar::TriangularSouth5Triangular tabs similar to those used in the Excel spreadsheet, for example
QTabBar::TriangularWest6Triangular tabs on the left of the pages.
QTabBar::TriangularEast7Triangular tabs on the right of the pages.

Property Documentation

count : const int

This property holds the number of tabs in the tab bar.

Access functions:

  • int count () const

currentIndex : int

This property holds the index of the tab bar's visible tab.

Access functions:

  • int currentIndex () const
  • void setCurrentIndex ( int index )

drawBase : bool

This property holds defines whether or not tabbar should draw it's base.

If true then QTabBar draws a base in relation to the styles overlab. Otherwise only the tabs are drawn.

Access functions:

  • bool drawBase () const
  • void setDrawBase ( bool drawTheBase )

See also QStyle::pixelMetric() and QStyle::PM_TabBarBaseOverlap.

shape : Shape

This property holds the shape of the tabs in the tab bar.

The value of this property is one of the following: RoundedNorth (default), RoundedSouth, TriangularNorth or TriangularBelow.

Access functions:

  • Shape shape () const
  • void setShape ( Shape shape )

See also Shape.


Member Function Documentation

QTabBar::QTabBar ( QWidget * parent = 0 )

Creates a new tab bar with the given parent.

QTabBar::~QTabBar ()

Destroys the tab bar.

int QTabBar::addTab ( const QString & text )

Adds a new tab with text text. Returns the new tab's index.

int QTabBar::addTab ( const QIcon & icon, const QString & text )

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

Adds a new tab with icon icon and text text. Returns the new tab's index.

void QTabBar::currentChanged ( int index )   [signal]

This signal is emitted when the tab bar's current tab changes. The new current has the given index.

int QTabBar::insertTab ( int index, const QString & text )

Inserts a new tab with text text at position index. If index is out of range, the new tab is appened. Returns the new tab's index.

int QTabBar::insertTab ( int index, const QIcon & icon, const QString & text )

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

Inserts a new tab with icon icon and text text at position index. If index is out of range, the new tab is appended. Returns the new tab's index.

bool QTabBar::isTabEnabled ( int index ) const

Returns true if the tab at position index is enabled; otherwise returns false.

void QTabBar::removeTab ( int index )

Removes the tab at position index.

void QTabBar::setTabData ( int index, const QVariant & data )

Sets the data of the tab at position index to data.

See also tabData().

void QTabBar::setTabEnabled ( int index, bool enabled )

If enabled is true then the tab at position index is enabled; otherwise the item at position index is disabled.

See also isTabEnabled().

void QTabBar::setTabIcon ( int index, const QIcon & icon )

Sets the icon of the tab at position index to icon.

See also tabIcon().

void QTabBar::setTabText ( int index, const QString & text )

Sets the text of the tab at position index to text.

See also tabText().

void QTabBar::setTabToolTip ( int index, const QString & tip )

Sets the tool tip of the tab at position index to tip.

See also tabToolTip().

QVariant QTabBar::tabData ( int index ) const

Returns the datad of the tab at position index, or a null variant if index is out of range.

See also setTabData().

QIcon QTabBar::tabIcon ( int index ) const

Returns the icon of the tab at position index, or a null icon if index is out of range.

See also setTabIcon().

void QTabBar::tabInserted ( int index )   [virtual protected]

This virtual handler is called after a new tab was added or inserted at position index.

See also tabRemoved().

void QTabBar::tabLayoutChange ()   [virtual protected]

This virtual handler is called whenever the tab layout changes.

See also tabRect().

QRect QTabBar::tabRect ( int index ) const

Returns the visual rectangle of the of the tab at position index, or a null rectangle if index is out of range.

void QTabBar::tabRemoved ( int index )   [virtual protected]

This virtual handler is called after a tab was removed from position index.

See also tabInserted().

QSize QTabBar::tabSizeHint ( int index ) const   [virtual protected]

Returns the size hint for the tab at position index.

QString QTabBar::tabText ( int index ) const

Returns the text of the tab at position index, or an empty string if index is out of range.

See also setTabText().

QString QTabBar::tabToolTip ( int index ) const

Returns the tool tip of the tab at position index, or an empty string if index is out of range.

See also setTabToolTip().

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 94
  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. Pourquoi les programmeurs sont-ils moins payés que les gestionnaires de programmes ? Manquent-ils de pouvoir de négociation ? 47
  4. Les développeurs ignorent-ils trop les failles découvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  5. Les développeurs détestent-ils les antivirus ? Un programmeur manifeste sa haine envers ces solutions de sécurité 12
  6. Quelles nouveautés de C++11 Visual C++ doit-il rapidement intégrer ? Donnez-nous votre avis 10
  7. Qt Commercial : Digia organise un webinar gratuit le 27 mars sur la conception d'interfaces utilisateur et d'applications avec le framework 0
Page suivante

Le blog Digia au hasard

Logo

Une nouvelle ère d'IHM 3D pour les automobiles

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