Eneboo - Documentación para desarrolladores
Tipos públicos | Slots públicos | Señales | Métodos públicos | Métodos protegidos | Propiedades | Amigas
Referencia de la Clase QTabWidget

The QTabWidget class provides a stack of tabbed widgets. Más...

#include <qtabwidget.h>

Diagrama de herencias de QTabWidget
QWidget QWidget QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject HierarchyView OutputWindow PropertyEditor QDesignerTabWidget

Lista de todos los miembros.

Tipos públicos

enum  TabPosition { Top, Bottom, Top, Bottom }
enum  TabShape { Rounded, Triangular, Rounded, Triangular }
enum  TabPosition { Top, Bottom, Top, Bottom }
enum  TabShape { Rounded, Triangular, Rounded, Triangular }

Slots públicos

void setCurrentPage (int)
virtual void showPage (QWidget *)
virtual void removePage (QWidget *)
void setCurrentPage (int)
virtual void showPage (QWidget *)
virtual void removePage (QWidget *)

Señales

void currentChanged (QWidget *)
void selected (const QString &)
void currentChanged (QWidget *)
void selected (const QString &)

Métodos públicos

 QTabWidget (QWidget *parent=0, const char *name=0, WFlags f=0)
 ~QTabWidget ()
virtual void addTab (QWidget *, const QString &)
virtual void addTab (QWidget *child, const QIconSet &iconset, const QString &label)
virtual void addTab (QWidget *, QTab *)
virtual void insertTab (QWidget *, const QString &, int index=-1)
virtual void insertTab (QWidget *child, const QIconSet &iconset, const QString &label, int index=-1)
virtual void insertTab (QWidget *, QTab *, int index=-1)
void changeTab (QWidget *, const QString &)
void changeTab (QWidget *child, const QIconSet &iconset, const QString &label)
bool isTabEnabled (QWidget *) const
void setTabEnabled (QWidget *, bool)
void setCornerWidget (QWidget *w, Qt::Corner corner=Qt::TopRight)
QWidgetcornerWidget (Qt::Corner corner=Qt::TopRight) const
QString tabLabel (QWidget *) const
void setTabLabel (QWidget *p, const QString &l)
QIconSet tabIconSet (QWidget *w) const
void setTabIconSet (QWidget *w, const QIconSet &iconset)
void removeTabToolTip (QWidget *w)
void setTabToolTip (QWidget *w, const QString &tip)
QString tabToolTip (QWidget *w) const
QWidgetcurrentPage () const
QWidgetpage (int) const
QString label (int) const
int currentPageIndex () const
int indexOf (QWidget *) const
QSize sizeHint () const
QSize minimumSizeHint () const
TabPosition tabPosition () const
void setTabPosition (TabPosition)
TabShape tabShape () const
void setTabShape (TabShape s)
int margin () const
void setMargin (int)
int count () const
 QTabWidget (QWidget *parent=0, const char *name=0, WFlags f=0)
 ~QTabWidget ()
virtual void addTab (QWidget *, const QString &)
virtual void addTab (QWidget *child, const QIconSet &iconset, const QString &label)
virtual void addTab (QWidget *, QTab *)
virtual void insertTab (QWidget *, const QString &, int index=-1)
virtual void insertTab (QWidget *child, const QIconSet &iconset, const QString &label, int index=-1)
virtual void insertTab (QWidget *, QTab *, int index=-1)
void changeTab (QWidget *, const QString &)
void changeTab (QWidget *child, const QIconSet &iconset, const QString &label)
bool isTabEnabled (QWidget *) const
void setTabEnabled (QWidget *, bool)
void setCornerWidget (QWidget *w, Qt::Corner corner=Qt::TopRight)
QWidgetcornerWidget (Qt::Corner corner=Qt::TopRight) const
QString tabLabel (QWidget *) const
void setTabLabel (QWidget *p, const QString &l)
QIconSet tabIconSet (QWidget *w) const
void setTabIconSet (QWidget *w, const QIconSet &iconset)
void removeTabToolTip (QWidget *w)
void setTabToolTip (QWidget *w, const QString &tip)
QString tabToolTip (QWidget *w) const
QWidgetcurrentPage () const
QWidgetpage (int) const
QString label (int) const
int currentPageIndex () const
int indexOf (QWidget *) const
QSize sizeHint () const
QSize minimumSizeHint () const
TabPosition tabPosition () const
void setTabPosition (TabPosition)
TabShape tabShape () const
void setTabShape (TabShape s)
int margin () const
void setMargin (int)
int count () const

Métodos protegidos

void showEvent (QShowEvent *)
void resizeEvent (QResizeEvent *)
void setTabBar (QTabBar *)
QTabBartabBar () const
void styleChange (QStyle &)
void updateMask ()
bool eventFilter (QObject *, QEvent *)
void showEvent (QShowEvent *)
void resizeEvent (QResizeEvent *)
void setTabBar (QTabBar *)
QTabBartabBar () const
void styleChange (QStyle &)
void updateMask ()
bool eventFilter (QObject *, QEvent *)

Propiedades

TabPosition tabPosition
 the position of the tabs in this tab widget
TabShape tabShape
 the shape of the tabs in this tab widget
int margin
 the margin in this tab widget
int currentPage
 the index position of the current tab page
int count
 the number of tabs in the tab bar

Amigas

class QTabDialog

Descripción detallada

The QTabWidget class provides a stack of tabbed widgets.

A tab widget provides a tab bar of tabs and a `page area' below (or above, see {TabPosition}) the tabs. Each tab is associated with a different widget (called a `page'). Only the current tab's page is shown in the page area; all the other tabs' pages are hidden. The user can show a different page by clicking on its tab or by pressing its Alt+{letter} accelerator if it has one.

The normal way to use QTabWidget is to do the following in the constructor: 1 Create a QTabWidget. Create a QWidget for each of the pages in the tab dialog, insert children into it, set up geometry management for it and use addTab() (or insertTab()) to set up a tab and keyboard accelerator for it. Connect to the signals and slots.

The position of the tabs is set with setTabPosition(), their shape with setTabShape(), and their margin with setMargin().

If you don't call addTab() and the QTabWidget is already visible, then the page you have created will not be visible. Don't confuse the object name you supply to the QWidget constructor and the tab label you supply to addTab(). addTab() takes a name which indicates an accelerator and is meaningful and descriptive to the user, whereas the widget name is used primarily for debugging.

The signal currentChanged() is emitted when the user selects a page.

The current page is available as an index position with currentPageIndex() or as a wiget pointer with currentPage(). You can retrieve a pointer to a page with a given index using page(), and can find the index position of a page with indexOf(). Use setCurrentPage() to show a particular page by index, or showPage() to show a page by widget pointer.

You can change a tab's label and iconset using changeTab() or setTabLabel() and setTabIconSet(). A tab page can be removed with removePage().

Each tab is either enabled or disabled at any given time (see setTabEnabled()). If a tab is enabled, the tab text is drawn normally and the user can select that tab. If it is disabled, the tab is drawn in a different way and the user cannot select that tab. Note that even if a tab is disabled, the page can still be visible, for example if all of the tabs happen to be disabled.

Although tab widgets can be a very good way to split up a complex dialog, it's also very easy to get into a mess. See QTabDialog for some design hints. An alternative is to use a QWidgetStack for which you provide some means of navigating between pages, for example, a QToolBar or a QListBox.

Most of the functionality in QTabWidget is provided by a QTabBar (at the top, providing the tabs) and a QWidgetStack (most of the area, organizing the individual pages).

qtabwidget-m.png
qtabwidget-w.png
Ver también:
QTabDialog, QToolBox

Documentación de las enumeraciones miembro de la clase

This enum type defines where QTabWidget draws the tab row: Top above the pages Bottom below the pages

Valores de enumeraciones:
Top 
Bottom 
Top 
Bottom 
Valores de enumeraciones:
Top 
Bottom 
Top 
Bottom 
Valores de enumeraciones:
Rounded 
Triangular 
Rounded 
Triangular 

This enum type defines the shape of the tabs: Rounded rounded look (normal) Triangular triangular look (very unusual, included for completeness)

Valores de enumeraciones:
Rounded 
Triangular 
Rounded 
Triangular 

Documentación del constructor y destructor

QTabWidget::QTabWidget ( QWidget parent = 0,
const char *  name = 0,
WFlags  f = 0 
)

Constructs a tabbed widget called name with parent parent, and widget flags f.

QTabWidget::~QTabWidget ( )
QTabWidget::QTabWidget ( QWidget parent = 0,
const char *  name = 0,
WFlags  f = 0 
)
QTabWidget::~QTabWidget ( )

Documentación de las funciones miembro

void QTabWidget::addTab ( QWidget child,
const QString label 
) [virtual]

Adds another tab and page to the tab view.

The new page is child; the tab's label is label. Note the difference between the widget name (which you supply to widget constructors and to setTabEnabled(), for example) and the tab label. The name is internal to the program and invariant, whereas the label is shown on-screen and may vary according to language and other factors.

If the tab's label contains an ampersand, the letter following the ampersand is used as an accelerator for the tab, e.g. if the label is "Bro\&wse" then Alt+W becomes an accelerator which will move the focus to this tab.

If you call addTab() after show() the screen will flicker and the user may be confused.

Adding the same child twice will have undefined behavior.

Ver también:
insertTab()
void QTabWidget::addTab ( QWidget child,
const QIconSet iconset,
const QString label 
) [virtual]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Adds another tab and page to the tab view.

This function is the same as addTab(), but with an additional iconset.

virtual void QTabWidget::addTab ( QWidget ,
const QString  
) [virtual]
virtual void QTabWidget::addTab ( QWidget child,
const QIconSet iconset,
const QString label 
) [virtual]
void QTabWidget::addTab ( QWidget child,
QTab tab 
) [virtual]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. This is a low-level function for adding tabs. It is useful if you are using setTabBar() to set a QTabBar subclass with an overridden QTabBar::paint() function for a subclass of QTab. The child is the new page and tab is the tab to put the child on.

virtual void QTabWidget::addTab ( QWidget ,
QTab  
) [virtual]
void QTabWidget::changeTab ( QWidget w,
const QIconSet iconset,
const QString label 
)

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Defines a new iconset and a new label for page {w}'s tab.

void QTabWidget::changeTab ( QWidget ,
const QString  
)
void QTabWidget::changeTab ( QWidget child,
const QIconSet iconset,
const QString label 
)
void QTabWidget::changeTab ( QWidget w,
const QString label 
)

Defines a new label for page {w}'s tab.

QWidget * QTabWidget::cornerWidget ( Qt::Corner  corner = Qt::TopRight) const

Returns the widget shown in the corner of the tab widget or 0.

QWidget* QTabWidget::cornerWidget ( Qt::Corner  corner = Qt::TopRight) const
int QTabWidget::count ( ) const

Reimplementado en QDesignerTabWidget.

int QTabWidget::count ( ) const

Reimplementado en QDesignerTabWidget.

void QTabWidget::currentChanged ( QWidget ) [signal]
void QTabWidget::currentChanged ( QWidget t0) [signal]

This signal is emitted whenever the current page changes. The parameter is the new current page.

Ver también:
currentPage(), showPage(), tabLabel()
QWidget* QTabWidget::currentPage ( ) const

Reimplementado en QDesignerTabWidget.

QWidget* QTabWidget::currentPage ( ) const

Reimplementado en QDesignerTabWidget.

int QTabWidget::currentPageIndex ( ) const
int QTabWidget::currentPageIndex ( ) const
bool QTabWidget::eventFilter ( QObject o,
QEvent e 
) [protected, virtual]

Reimplementado de QObject.

Reimplementado en QDesignerTabWidget.

bool QTabWidget::eventFilter ( QObject ,
QEvent  
) [protected, virtual]

Filters events if this object has been installed as an event filter for the watched object.

In your reimplementation of this function, if you want to filter the event e, out, i.e. stop it being handled further, return TRUE; otherwise return FALSE.

Example:

    class MyMainWindow : public QMainWindow
    {
    public:
        MyMainWindow( QWidget *parent = 0, const char *name = 0 );

    protected:
        bool eventFilter( QObject *obj, QEvent *ev );

    private:
        QTextEdit *textEdit;
    };

    MyMainWindow::MyMainWindow( QWidget *parent, const char *name )
        : QMainWindow( parent, name )
    {
        textEdit = new QTextEdit( this );
        setCentralWidget( textEdit );
        textEdit->installEventFilter( this );
    }

    bool MyMainWindow::eventFilter( QObject *obj, QEvent *ev )
    {
        if ( obj == textEdit ) {
            if ( e->type() == QEvent::KeyPress ) {
                QKeyEvent *k = (QKeyEvent*)ev;
                qDebug( "Ate key press %d", k->key() );
                return TRUE;
            } else {
                return FALSE;
            }
        } else {
            // pass the event on to the parent class
            return QMainWindow::eventFilter( obj, ev );
        }
    }

Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.

Atención:
If you delete the receiver object in this function, be sure to return TRUE. Otherwise, Qt will forward the event to the deleted object and the program might crash.
Ver también:
installEventFilter()

Reimplementado de QObject.

Reimplementado en QDesignerTabWidget.

int QTabWidget::indexOf ( QWidget ) const
int QTabWidget::indexOf ( QWidget w) const

Returns the index position of page w, or -1 if the widget cannot be found.

void QTabWidget::insertTab ( QWidget child,
const QString label,
int  index = -1 
) [virtual]

Inserts another tab and page to the tab view.

The new page is child; the tab's label is label. Note the difference between the widget name (which you supply to widget constructors and to setTabEnabled(), for example) and the tab label. The name is internal to the program and invariant, whereas the label is shown on-screen and may vary according to language and other factors.

If the tab's label contains an ampersand, the letter following the ampersand is used as an accelerator for the tab, e.g. if the label is "Bro\&wse" then Alt+W becomes an accelerator which will move the focus to this tab.

If index is not specified, the tab is simply appended. Otherwise it is inserted at the specified position.

If you call insertTab() after show(), the screen will flicker and the user may be confused.

Ver también:
addTab()
void QTabWidget::insertTab ( QWidget child,
const QIconSet iconset,
const QString label,
int  index = -1 
) [virtual]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Inserts another tab and page to the tab view.

This function is the same as insertTab(), but with an additional iconset.

void QTabWidget::insertTab ( QWidget child,
QTab tab,
int  index = -1 
) [virtual]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. This is a lower-level method for inserting tabs, similar to the other insertTab() method. It is useful if you are using setTabBar() to set a QTabBar subclass with an overridden QTabBar::paint() function for a subclass of QTab. The child is the new page, tab is the tab to put the child on and index is the position in the tab bar that this page should occupy.

virtual void QTabWidget::insertTab ( QWidget ,
const QString ,
int  index = -1 
) [virtual]
virtual void QTabWidget::insertTab ( QWidget child,
const QIconSet iconset,
const QString label,
int  index = -1 
) [virtual]
virtual void QTabWidget::insertTab ( QWidget ,
QTab ,
int  index = -1 
) [virtual]
bool QTabWidget::isTabEnabled ( QWidget w) const

Returns TRUE if the page w is enabled; otherwise returns FALSE.

Ver también:
setTabEnabled(), QWidget::isEnabled()
bool QTabWidget::isTabEnabled ( QWidget ) const
QString QTabWidget::label ( int  ) const
QString QTabWidget::label ( int  index) const

Returns the label of the tab at index position index or QString::null if the index is out of range.

int QTabWidget::margin ( ) const
int QTabWidget::margin ( ) const
QSize QTabWidget::minimumSizeHint ( ) const [virtual]

Reimplementado de QWidget.

QSize QTabWidget::minimumSizeHint ( ) const [virtual]

Returns a suitable minimum size for the tab widget.

Reimplementado de QWidget.

QWidget* QTabWidget::page ( int  ) const
QWidget * QTabWidget::page ( int  index) const

Returns the tab page at index position index or 0 if the index is out of range.

void QTabWidget::removePage ( QWidget w) [virtual, slot]

Removes page w from this stack of widgets. Does not delete w.

Ver también:
addTab(), showPage(), QWidgetStack::removeWidget()
virtual void QTabWidget::removePage ( QWidget ) [virtual, slot]
void QTabWidget::removeTabToolTip ( QWidget w)

Removes the tab tool tip for page w. If the page does not have a tip, nothing happens.

Ver también:
setTabToolTip(), tabToolTip()
void QTabWidget::removeTabToolTip ( QWidget w)
void QTabWidget::resizeEvent ( QResizeEvent e) [protected, virtual]

Reimplementado de QWidget.

void QTabWidget::resizeEvent ( QResizeEvent ) [protected, virtual]

This event handler can be reimplemented in a subclass to receive widget resize events. When resizeEvent() is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::oldSize().

The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler.

Widgets that have been created with the WNoAutoErase flag will not be erased. Nevertheless, they will receive a paint event for their entire area afterwards. Again, no drawing needs to be done inside this handler.

The default implementation calls updateMask() if the widget has automatic masking enabled.

Ver también:
moveEvent(), event(), resize(), QResizeEvent, paintEvent()

Reimplementado de QWidget.

void QTabWidget::selected ( const QString t0) [signal]
void QTabWidget::selected ( const QString ) [signal]
void QTabWidget::setCornerWidget ( QWidget w,
Qt::Corner  corner = Qt::TopRight 
)

Sets widget w to be the shown in the specified corner of the tab widget.

Only the horizontal element of the corner will be used.

Ver también:
cornerWidget(), setTabPosition()
void QTabWidget::setCornerWidget ( QWidget w,
Qt::Corner  corner = Qt::TopRight 
)
void QTabWidget::setCurrentPage ( int  ) [slot]

Reimplementado en QDesignerTabWidget.

void QTabWidget::setCurrentPage ( int  index) [slot]

Reimplementado en QDesignerTabWidget.

void QTabWidget::setMargin ( int  w)
void QTabWidget::setMargin ( int  )
void QTabWidget::setTabBar ( QTabBar ) [protected]
void QTabWidget::setTabBar ( QTabBar tb) [protected]

Replaces the dialog's QTabBar heading with the tab bar tb. Note that this must be called before any tabs have been added, or the behavior is undefined.

Ver también:
tabBar()
void QTabWidget::setTabEnabled ( QWidget w,
bool  enable 
)

If enable is TRUE, page w is enabled; otherwise page w is disabled. The page's tab is redrawn appropriately.

QTabWidget uses QWidget::setEnabled() internally, rather than keeping a separate flag.

Note that even a disabled tab/page may be visible. If the page is visible already, QTabWidget will not hide it; if all the pages are disabled, QTabWidget will show one of them.

Ver también:
isTabEnabled(), QWidget::setEnabled()
void QTabWidget::setTabEnabled ( QWidget ,
bool   
)
void QTabWidget::setTabIconSet ( QWidget w,
const QIconSet iconset 
)

Sets the iconset for page w to iconset.

void QTabWidget::setTabIconSet ( QWidget w,
const QIconSet iconset 
)
void QTabWidget::setTabLabel ( QWidget w,
const QString l 
)

Sets the tab label for page w to l

void QTabWidget::setTabLabel ( QWidget p,
const QString l 
)
void QTabWidget::setTabPosition ( TabPosition  )
void QTabWidget::setTabPosition ( TabPosition  pos)
void QTabWidget::setTabShape ( TabShape  s)
void QTabWidget::setTabShape ( TabShape  s)
void QTabWidget::setTabToolTip ( QWidget w,
const QString tip 
)

Sets the tab tool tip for page w to tip.

Ver también:
removeTabToolTip(), tabToolTip()
void QTabWidget::setTabToolTip ( QWidget w,
const QString tip 
)
void QTabWidget::showEvent ( QShowEvent ) [protected, virtual]

This event handler can be reimplemented in a subclass to receive widget show events.

Non-spontaneous show events are sent to widgets immediately before they are shown. The spontaneous show events of top-level widgets are delivered afterwards.

Ver también:
event(), QShowEvent

Reimplementado de QWidget.

void QTabWidget::showEvent ( QShowEvent ) [protected, virtual]

Reimplementado de QWidget.

void QTabWidget::showPage ( QWidget w) [virtual, slot]

Ensures that page w is shown. This is useful mainly for accelerators.

Atención:
Used carelessly, this function can easily surprise or confuse the user.
Ver también:
QTabBar::setCurrentTab()
virtual void QTabWidget::showPage ( QWidget ) [virtual, slot]
QSize QTabWidget::sizeHint ( ) const [virtual]

Reimplementado de QWidget.

QSize QTabWidget::sizeHint ( ) const [virtual]

Reimplementado de QWidget.

void QTabWidget::styleChange ( QStyle ) [protected, virtual]

This virtual function is called when the style of the widgets changes. oldStyle is the previous GUI style; you can get the new style from style().

Reimplement this function if your widget needs to know when its GUI style changes. You will almost certainly need to update the widget using update().

The default implementation updates the widget including its geometry.

Ver también:
QApplication::setStyle(), style(), update(), updateGeometry()

Reimplementado de QWidget.

void QTabWidget::styleChange ( QStyle old) [protected, virtual]

Reimplementado de QWidget.

QTabBar * QTabWidget::tabBar ( ) const [protected]

Returns the current QTabBar.

Ver también:
setTabBar()

Reimplementado en QDesignerTabWidget.

QTabBar* QTabWidget::tabBar ( ) const [protected]

Reimplementado en QDesignerTabWidget.

QIconSet QTabWidget::tabIconSet ( QWidget w) const

Returns the iconset of page w or a null iconset if w is not a tab page or does not have an iconset.

QIconSet QTabWidget::tabIconSet ( QWidget w) const
QString QTabWidget::tabLabel ( QWidget ) const
QString QTabWidget::tabLabel ( QWidget w) const

Returns the label text for the tab on page w.

TabPosition QTabWidget::tabPosition ( ) const
TabPosition QTabWidget::tabPosition ( ) const
TabShape QTabWidget::tabShape ( ) const
TabShape QTabWidget::tabShape ( ) const
QString QTabWidget::tabToolTip ( QWidget w) const
QString QTabWidget::tabToolTip ( QWidget w) const

Returns the tab tool tip for page w or QString::null if no tool tip has been set.

Ver también:
setTabToolTip(), removeTabToolTip()
void QTabWidget::updateMask ( ) [protected, virtual]

Reimplementado de QWidget.

void QTabWidget::updateMask ( ) [protected, virtual]

This function can be reimplemented in a subclass to support transparent widgets. It should be called whenever a widget changes state in a way that means that the shape mask must be recalculated.

Ver también:
setAutoMask(), updateMask(), setMask(), clearMask()

Reimplementado de QWidget.


Documentación de las funciones relacionadas y clases amigas

QTabDialog [friend]

Documentación de propiedades

int QTabWidget::count [read]

the number of tabs in the tab bar

int QTabWidget::currentPage [read, write]

the index position of the current tab page

Returns a pointer to the page currently being displayed by the tab dialog. The tab dialog does its best to make sure that this value is never 0 (but if you try hard enough, it can be).

Ver también:
QTabBar::currentTab()

Reimplementado en QDesignerTabWidget.

int QTabWidget::margin [read, write]

the margin in this tab widget

The margin is the distance between the innermost pixel of the frame and the outermost pixel of the pages.

TabPosition QTabWidget::tabPosition [read, write]

the position of the tabs in this tab widget

Possible values for this property are QTabWidget::Top and QTabWidget::Bottom.

Ver también:
TabPosition
TabShape QTabWidget::tabShape [read, write]

the shape of the tabs in this tab widget

Possible values for this property are QTabWidget::Rounded (default) or QTabWidget::Triangular.

Ver también:
TabShape

La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'