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  ·  Classes  ·  Annotées  ·  Hiérarchie  ·  Fonctions  ·  Structure  · 

QTabBar Class Reference


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

#include <qtabbar.h>

Inherits QWidget.

List of all member functions.

Public Members

  • QTabBar ( QWidget * parent = 0, const char * name = 0 ) 
  • ~QTabBar () 
  • enum Shape { RoundedAbove, RoundedBelow, TriangularAbove, TriangularBelow }
  • Shape shape () const
  • virtual void setShape ( Shape ) 
  • virtual int addTab ( QTab * ) 
  • virtual int insertTab ( QTab *, int index = -1 ) 
  • virtual void removeTab ( QTab * ) 
  • virtual void setTabEnabled ( int, bool ) 
  • bool isTabEnabled ( int ) const
  • int currentTab () const
  • int keyboardFocusTab () const
  • QTab* tab ( int ) 
  • int count () const
  • virtual void layoutTabs () 

Public Slots

Signals

Protected Members

  • virtual void paint ( QPainter *, QTab *, bool ) const
  • virtual void paintLabel ( QPainter *, const QRect &, QTab *, bool ) const
  • virtual QTab* selectTab ( const QPoint & p ) const
  • virtual void updateMask () 
  • virtual void paintEvent ( QPaintEvent * ) 
  • QList<QTab>* tabList () 

Properties

TypeNameREADWRITEOptions
ShapeshapeshapesetShape 
intcurrentTabcurrentTabsetCurrentTab 
intcountcount  
intkeyboardFocusTabkeyboardFocusTab  

Detailed Description

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

The class is quite simple; it draws the tabs in one of four shapes and emits a signal when one is selected. It can be subclassed to tailor the look and feel.

QTabBar itself support four possible shapes, described in the QTabBar::Shape documentation.

The choice of tab shape is still a matter of taste, to a large degree. Tab dialogs (preferences and the like) invariably use RoundedAbove and nobody uses TriangularAbove. Tab controls in windows other than dialogs almost always either RoundedBelow or TriangularBelow. Many spreadsheets and other tab controls where all the pages are essentially similar to use TriangularBelow, while RoundedBelow is used mostly when the pages are different (e.g. a multi-page tool palette). There is no strong tradition yet, however, so use your taste and create the tradition.

The most important part of QTabBar's API is the signal selected(). It's emitted whenever the selected page changes (even at startup, when the selected page changes from 'none'). There are also a slot, setCurrentTab(), which can be used to select a page programmatically.

QTabBar creates automatic accelerator keys in the manner of QButton; e.g. if a tab's label is "&Graphics" Alt-G becomes an accelerator key for switching to that tab.

The following virtual functions may need to be reimplemented:

  • paint() paints a single tab. paintEvent() calls paint() for each tab in such a way that any overlap will look right.
  • addTab() creates a new tab and adds it to the bar.
  • selectTab() decides which, if any, tab the user selects with the mouse.


Member Type Documentation

QTabBar::Shape

This enum type lists the built-in shapes supported by QTabBar:
  • RoundedAbove - the normal rounded look, above the pages
  • RoundedBelow - the normal rounded look, below the pages
  • TriangularAbove - triangular tabs, above the pages (very unusual, included for completeness)
  • TriangularBelow - triangular tabs, similar to those used in e.g. the spreadsheet Excel


Member Function Documentation

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

Constructs a new, empty tab bar.

QTabBar::~QTabBar ()

Destroys the tab control, freeing memory used.

int QTabBar::addTab ( QTab * newTab ) [virtual]

Adds newTab to the tab control.

Allocates a new id, sets newTab's id, locates it just to the right of the existing tabs, inserts an accelerator if the tab's label contains the string "&p" for some value of p, adds it to the bar, and returns the newly allocated id.

int QTabBar::count () const

Returns the number of tabs in the tab bar.

See also tab().

int QTabBar::currentTab () const

If a page is currently visible, returns its ID. If no page is currently visible, returns either -1 or the ID of one of the pages.

Even if the return value is not -1, you cannot assume either that the user can see the relevant page, or that the tab is enabled.

When you need to display something, the return value from this function represents the best page to display. That's all.

See also selected().

void QTabBar::focusInEvent ( QFocusEvent * ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QTabBar::focusOutEvent ( QFocusEvent * ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

int QTabBar::insertTab ( QTab * newTab, int index = -1 ) [virtual]

Inserts newTab to the tab control.

If index is not specified, the tab is simply added. Otherwise it's inserted at the specified position.

Allocates a new id, sets newTab's id, locates it respectively, inserts an accelerator if the tab's label contains the string "&p" for some value of p, adds it to the bar, and returns the newly allocated id.

bool QTabBar::isTabEnabled ( int id ) const

Returns TRUE if the tab with id id is enabled, or FALSE if it is disabled or there is no such tab.

See also setTabEnabled().

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

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

int QTabBar::keyboardFocusTab () const

If this tab control has keyboard focus, returns the ID of the tab Space will select. Otherwise, returns -1.

void QTabBar::layoutTabs () [virtual]

Layout all existing tabs (i.e. setting their r attribute) according to their label and their iconset.

QSize QTabBar::minimumSizeHint () const [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

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

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QTabBar::mouseReleaseEvent ( QMouseEvent * ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QTabBar::paint ( QPainter * p, QTab * t, bool selected ) const [virtual protected]

Paint the single tab t using p. If and only if selected is TRUE, t is currently selected.

This virtual function may be reimplemented to change the look of QTabBar. If you decide to reimplement it, you may also need to reimplement sizeHint().

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

Repaints the tab row. All the painting is done by paint(); paintEvent() only decides which tabs need painting and in what order.

See also paint().

Reimplemented from QWidget.

void QTabBar::paintLabel ( QPainter * p, const QRect & br, QTab * t, bool has_focus ) const [virtual protected]

Paints the label of tab t centered in rectangle br using painter p and draws a focus indication if has_focus is TRUE.

void QTabBar::removeTab ( QTab * t ) [virtual]

Removes tab t from the tab control.

void QTabBar::resizeEvent ( QResizeEvent * ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

QTab * QTabBar::selectTab ( const QPoint & p ) const [virtual protected]

This virtual functions is called by the mouse event handlers to determine which tab is pressed. The default implementation returns a pointer to the tab whose bounding rectangle contains p, if exactly one tab's bounding rectangle contains p. It returns 0 else.

See also mousePressEvent() and mouseReleaseEvent().

void QTabBar::selected ( int id ) [signal]

QTabBar emits this signal whenever any tab is selected, whether by the program or the user. The argument id is the ID if the tab as returned by addTab().

show() is guaranteed to emit this signal, so that you can display your page in a slot connected to this signal.

void QTabBar::setCurrentTab ( QTab * tab ) [virtual slot]

Raises tab and emits the selected() signal unless the tab was already current.

See also currentTab() and selected().

void QTabBar::setCurrentTab ( int id ) [virtual slot]

Raises the tab with ID id and emits the selected() signal.

See also currentTab(), selected() and tab().

void QTabBar::setShape ( Shape s )

Sets the shape of this tab bar to s and refreshes the bar.

void QTabBar::setTabEnabled ( int id, bool enabled ) [virtual]

Enable tab id if enable is TRUE, or disable it if enable is FALSE. If id is currently selected, setTabEnabled() makes another tab selected.

setTabEnabled() updates the display respectively if this causes a change in id's status.

See also update() and isTabEnabled().

QTabBar::Shape QTabBar::shape() const

Returns the shape of this tab bar.

See also setShape().

void QTabBar::show () [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

QSize QTabBar::sizeHint () const [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

QSizePolicy QTabBar::sizePolicy () const [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QTabBar::styleChange ( QStyle & old ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

QTab * QTabBar::tab ( int id )

Returns a pointer to the tab with ID id, or 0 if there is no such tab.

See also count().

QList<QTab> * QTabBar::tabList () [protected]

The list of QTab objects added.

void QTabBar::updateMask () [virtual protected]

Draws the mask for this tab bar.

Reimplemented from QWidget.


Search the documentation, FAQ, qt-interest archive and more (uses www.trolltech.com):


This file is part of the Qt toolkit, copyright © 1995-2005 Trolltech, all rights reserved.

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 82
  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. 2017 : un quinquennat pour une nouvelle version du C++ ? Possible, selon Herb Sutter 6
Page suivante

Le Qt Developer Network au hasard

Logo

La création de colonnes dans une ListView en QML

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. 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 2.3
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