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 QTabBar

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

#include <qtabbar.h>

Diagrama de herencias de QTabBar
QWidget QWidget QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject

Lista de todos los miembros.

Tipos públicos

enum  Shape {
  RoundedAbove, RoundedBelow, TriangularAbove, TriangularBelow,
  RoundedAbove, RoundedBelow, TriangularAbove, TriangularBelow
}
enum  Shape {
  RoundedAbove, RoundedBelow, TriangularAbove, TriangularBelow,
  RoundedAbove, RoundedBelow, TriangularAbove, TriangularBelow
}

Slots públicos

virtual void setCurrentTab (int)
virtual void setCurrentTab (QTab *)
virtual void setCurrentTab (int)
virtual void setCurrentTab (QTab *)

Señales

void selected (int)
void layoutChanged ()
void selected (int)
void layoutChanged ()

Métodos públicos

 QTabBar (QWidget *parent=0, const char *name=0)
 ~QTabBar ()
Shape shape () const
virtual void setShape (Shape)
void show ()
virtual int addTab (QTab *)
virtual int insertTab (QTab *, int index=-1)
virtual void removeTab (QTab *)
virtual void setTabEnabled (int, bool)
bool isTabEnabled (int) const
QSize sizeHint () const
QSize minimumSizeHint () const
int currentTab () const
int keyboardFocusTab () const
QTabtab (int) const
QTabtabAt (int) const
int indexOf (int) const
int count () const
virtual void layoutTabs ()
virtual QTabselectTab (const QPoint &p) const
void removeToolTip (int index)
void setToolTip (int index, const QString &tip)
QString toolTip (int index) const
 QTabBar (QWidget *parent=0, const char *name=0)
 ~QTabBar ()
Shape shape () const
virtual void setShape (Shape)
void show ()
virtual int addTab (QTab *)
virtual int insertTab (QTab *, int index=-1)
virtual void removeTab (QTab *)
virtual void setTabEnabled (int, bool)
bool isTabEnabled (int) const
QSize sizeHint () const
QSize minimumSizeHint () const
int currentTab () const
int keyboardFocusTab () const
QTabtab (int) const
QTabtabAt (int) const
int indexOf (int) const
int count () const
virtual void layoutTabs ()
virtual QTabselectTab (const QPoint &p) const
void removeToolTip (int index)
void setToolTip (int index, const QString &tip)
QString toolTip (int index) const

Métodos protegidos

virtual void paint (QPainter *, QTab *, bool) const
virtual void paintLabel (QPainter *, const QRect &, QTab *, bool) const
void focusInEvent (QFocusEvent *e)
void focusOutEvent (QFocusEvent *e)
void resizeEvent (QResizeEvent *)
void paintEvent (QPaintEvent *)
void mousePressEvent (QMouseEvent *)
void mouseMoveEvent (QMouseEvent *)
void mouseReleaseEvent (QMouseEvent *)
void keyPressEvent (QKeyEvent *)
void styleChange (QStyle &)
void fontChange (const QFont &)
bool event (QEvent *e)
QPtrList< QTab > * tabList ()
virtual void paint (QPainter *, QTab *, bool) const
virtual void paintLabel (QPainter *, const QRect &, QTab *, bool) const
void focusInEvent (QFocusEvent *e)
void focusOutEvent (QFocusEvent *e)
void resizeEvent (QResizeEvent *)
void paintEvent (QPaintEvent *)
void mousePressEvent (QMouseEvent *)
void mouseMoveEvent (QMouseEvent *)
void mouseReleaseEvent (QMouseEvent *)
void keyPressEvent (QKeyEvent *)
void styleChange (QStyle &)
void fontChange (const QFont &)
bool event (QEvent *e)
QPtrList< QTab > * tabList ()

Propiedades

Shape shape
 the shape of the tabs in the tab bar
int currentTab
 the id of the tab bar's visible tab
int count
 the number of tabs in the tab bar
int keyboardFocusTab
 the id of the tab that has the keyboard focus

Amigas

class QTabBarToolTip
class QTab

Descripción detallada

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} and a {QTabDialog}.

The choice of tab shape is a matter of taste, although tab dialogs (for preferences and similar) invariably use RoundedAbove; nobody uses TriangularAbove. Tab controls in windows other than dialogs almost always use either RoundedBelow or TriangularBelow. Many spreadsheets and other tab controls in which all the pages are essentially similar use TriangularBelow, whereas RoundedBelow is used mostly when the pages are different (e.g. a multi-page tool palette).

The most important part of QTabBar's API is the selected() signal. This is emitted whenever the selected page changes (even at startup, when the selected page changes from 'none'). There is 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 so that any overlap will look right. addTab() creates a new tab and adds it to the bar. selectTab() decides which tab, if any, the user selects with the mouse.

The index of the current tab is returned by currentTab(). The tab with a particular index is returned by tabAt(), the tab with a particular id is returned by tab(). The index of a tab is returned by indexOf(). The current tab can be set by index or tab pointer using one of the setCurrentTab() functions.

qtabbar-m.png
qtabbar-w.png

Documentación de las enumeraciones miembro de la clase

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 the Excel spreadsheet, for example

Valores de enumeraciones:
RoundedAbove 
RoundedBelow 
TriangularAbove 
TriangularBelow 
RoundedAbove 
RoundedBelow 
TriangularAbove 
TriangularBelow 
Valores de enumeraciones:
RoundedAbove 
RoundedBelow 
TriangularAbove 
TriangularBelow 
RoundedAbove 
RoundedBelow 
TriangularAbove 
TriangularBelow 

Documentación del constructor y destructor

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

Constructs a new, empty tab bar; the parent and name arguments are passed on to the QWidget constructor.

QTabBar::~QTabBar ( )

Destroys the tab control, freeing memory used.

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

Documentación de las funciones miembro

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

Adds the tab, newTab, to the tab control.

Sets newTab's id to a new id and places the tab just to the right of the existing tabs. 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. Returns the id.

Ver también:
insertTab()
virtual int QTabBar::addTab ( QTab ) [virtual]
int QTabBar::count ( ) const
int QTabBar::count ( ) const
int QTabBar::currentTab ( ) const
int QTabBar::currentTab ( ) const
bool QTabBar::event ( QEvent e) [protected, virtual]

Reimplementado de QWidget.

bool QTabBar::event ( QEvent e) [protected, virtual]

This is the main event handler; it handles event e. You can reimplement this function in a subclass, but we recommend using one of the specialized event handlers instead.

The main event handler first passes an event through all event filters that have been installed. If none of the filters intercept the event, it calls one of the specialized event handlers.

Key press and release events are treated differently from other events. event() checks for Tab and Shift+Tab and tries to move the focus appropriately. If there is no widget to move the focus to (or the key press is not Tab or Shift+Tab), event() calls keyPressEvent().

This function returns TRUE if it is able to pass the event over to someone (i.e. someone wanted the event); otherwise returns FALSE.

Ver también:
closeEvent(), focusInEvent(), focusOutEvent(), enterEvent(), keyPressEvent(), keyReleaseEvent(), leaveEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), mousePressEvent(), mouseReleaseEvent(), moveEvent(), paintEvent(), resizeEvent(), QObject::event(), QObject::timerEvent()

Reimplementado de QWidget.

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

This event handler can be reimplemented in a subclass to receive keyboard focus events (focus received) for the widget.

A widget normally must setFocusPolicy() to something other than NoFocus in order to receive focus events. (Note that the application programmer can call setFocus() on any widget, even those that do not normally accept focus.)

The default implementation updates the widget (except for toplevel widgets that do not specify a focusPolicy() ). It also calls setMicroFocusHint(), hinting any system-specific input tools about the focus of the user's attention.

Ver también:
focusOutEvent(), setFocusPolicy(), keyPressEvent(), keyReleaseEvent(), event(), QFocusEvent

Reimplementado de QWidget.

void QTabBar::focusInEvent ( QFocusEvent e) [protected, virtual]

Reimplementado de QWidget.

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

This event handler can be reimplemented in a subclass to receive keyboard focus events (focus lost) for the widget.

A widget normally must setFocusPolicy() to something other than NoFocus in order to receive focus events. (Note that the application programmer can call setFocus() on any widget, even those that do not normally accept focus.)

The default implementation updates the widget (except for toplevel widgets that do not specify a focusPolicy() ). It also calls setMicroFocusHint(), hinting any system-specific input tools about the focus of the user's attention.

Ver también:
focusInEvent(), setFocusPolicy(), keyPressEvent(), keyReleaseEvent(), event(), QFocusEvent

Reimplementado de QWidget.

void QTabBar::focusOutEvent ( QFocusEvent e) [protected, virtual]

Reimplementado de QWidget.

void QTabBar::fontChange ( const QFont oldFont) [protected, virtual]

This virtual function is called from setFont(). oldFont is the previous font; you can get the new font from font().

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

The default implementation updates the widget including its geometry.

Ver también:
setFont(), font(), update(), updateGeometry()

Reimplementado de QWidget.

void QTabBar::fontChange ( const QFont oldFont) [protected, virtual]

This virtual function is called from setFont(). oldFont is the previous font; you can get the new font from font().

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

The default implementation updates the widget including its geometry.

Ver también:
setFont(), font(), update(), updateGeometry()

Reimplementado de QWidget.

int QTabBar::indexOf ( int  ) const
int QTabBar::indexOf ( int  id) const

Returns the position index of the tab with id id or -1 if no tab has this id.

Ver también:
tabAt()
int QTabBar::insertTab ( QTab newTab,
int  index = -1 
) [virtual]

Inserts the tab, newTab, into the tab control.

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

Sets newTab's id to a new id. 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. Returns the id.

Ver también:
addTab()
virtual int QTabBar::insertTab ( QTab ,
int  index = -1 
) [virtual]
bool QTabBar::isTabEnabled ( int  id) const

Returns TRUE if the tab with id id exists and is enabled; otherwise returns FALSE.

Ver también:
setTabEnabled()
bool QTabBar::isTabEnabled ( int  ) const
int QTabBar::keyboardFocusTab ( ) const
int QTabBar::keyboardFocusTab ( ) const
void QTabBar::keyPressEvent ( QKeyEvent e) [protected, virtual]

Reimplementado de QWidget.

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

This event handler, for event e, can be reimplemented in a subclass to receive key press events for the widget.

A widget must call setFocusPolicy() to accept focus initially and have focus in order to receive a key press event.

If you reimplement this handler, it is very important that you explicitly ignore the event if you do not understand it, so that the widget's parent can interpret it; otherwise, the event will be implicitly accepted. Although top-level widgets are able to choose whether to accept or ignore unknown events because they have no parent widgets that could otherwise handle them, it is good practice to explicitly ignore events to make widgets as reusable as possible.

The default implementation closes popup widgets if the user presses Esc. Otherwise the event is ignored.

Ver también:
keyReleaseEvent(), QKeyEvent::ignore(), setFocusPolicy(), focusInEvent(), focusOutEvent(), event(), QKeyEvent

Reimplementado de QWidget.

void QTabBar::layoutChanged ( ) [signal]
void QTabBar::layoutChanged ( ) [signal]

QTabBar emits the signal whenever the layout of the tab bar has been recalculated, for example when the contents of a tab change.

void QTabBar::layoutTabs ( ) [virtual]

Lays out all existing tabs according to their label and their iconset.

virtual void QTabBar::layoutTabs ( ) [virtual]
QSize QTabBar::minimumSizeHint ( ) const [virtual]

Reimplementado de QWidget.

QSize QTabBar::minimumSizeHint ( ) const [virtual]

Reimplementado de QWidget.

void QTabBar::mouseMoveEvent ( QMouseEvent e) [protected, virtual]

Reimplementado de QWidget.

void QTabBar::mouseMoveEvent ( QMouseEvent e) [protected, virtual]

This event handler, for event e, can be reimplemented in a subclass to receive mouse move events for the widget.

If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.

QMouseEvent::pos() reports the position of the mouse cursor, relative to this widget. For press and release events, the position is usually the same as the position of the last mouse move event, but it might be different if the user's hand shakes. This is a feature of the underlying window system, not Qt.

Ver también:
setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), event(), QMouseEvent

Reimplementado de QWidget.

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

Reimplementado de QWidget.

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

This event handler, for event e, can be reimplemented in a subclass to receive mouse press events for the widget.

If you create new widgets in the mousePressEvent() the mouseReleaseEvent() may not end up where you expect, depending on the underlying window system (or X11 window manager), the widgets' location and maybe more.

The default implementation implements the closing of popup widgets when you click outside the window. For other widget types it does nothing.

Ver también:
mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event(), QMouseEvent

Reimplementado de QWidget.

void QTabBar::mouseReleaseEvent ( QMouseEvent e) [protected, virtual]

Reimplementado de QWidget.

void QTabBar::mouseReleaseEvent ( QMouseEvent e) [protected, virtual]

This event handler, for event e, can be reimplemented in a subclass to receive mouse release events for the widget.

Ver también:
mouseReleaseEvent(), mouseDoubleClickEvent(), mouseMoveEvent(), event(), QMouseEvent

Reimplementado de QWidget.

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

Paints the tab t using painter p. If and only if selected is TRUE, t is drawn 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().

virtual void QTabBar::paint ( QPainter ,
QTab ,
bool   
) const [protected, virtual]
void QTabBar::paintEvent ( QPaintEvent ) [protected, virtual]

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

A paint event is a request to repaint all or part of the widget. It can happen as a result of repaint() or update(), or because the widget was obscured and has now been uncovered, or for many other reasons.

Many widgets can simply repaint their entire surface when asked to, but some slow widgets need to optimize by painting only the requested region: QPaintEvent::region(). This speed optimization does not change the result, as painting is clipped to that region during event processing. QListView and QCanvas do this, for example.

Qt also tries to speed up painting by merging multiple paint events into one. When update() is called several times or the window system sends several paint events, Qt merges these events into one event with a larger region (see QRegion::unite()). repaint() does not permit this optimization, so we suggest using update() when possible.

When the paint event occurs, the update region has normally been erased, so that you're painting on the widget's background. There are a couple of exceptions and QPaintEvent::erased() tells you whether the widget has been erased or not.

The background can be set using setBackgroundMode(), setPaletteBackgroundColor() or setBackgroundPixmap(). The documentation for setBackgroundMode() elaborates on the background; we recommend reading it.

Ver también:
event(), repaint(), update(), QPainter, QPixmap, QPaintEvent

Reimplementado de QWidget.

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

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

Ver también:
paint()

Reimplementado de QWidget.

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

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

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

Removes tab t from the tab control, and deletes the tab.

void QTabBar::removeToolTip ( int  index)
void QTabBar::removeToolTip ( int  index)

Removes the tool tip for the tab at index position index.

void QTabBar::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 QTabBar::resizeEvent ( QResizeEvent ) [protected, virtual]

Reimplementado de QWidget.

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

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

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

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

This virtual function 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. Otherwise it returns 0.

Ver también:
mousePressEvent() mouseReleaseEvent()
virtual QTab* QTabBar::selectTab ( const QPoint p) const [virtual]
virtual void QTabBar::setCurrentTab ( QTab ) [virtual, slot]
void QTabBar::setCurrentTab ( int  id) [virtual, slot]
void QTabBar::setCurrentTab ( QTab tab) [virtual, slot]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Raises tab and emits the selected() signal unless the tab was already current.

Ver también:
currentTab() selected()
virtual void QTabBar::setCurrentTab ( int  ) [virtual, slot]
virtual void QTabBar::setShape ( Shape  ) [virtual]
void QTabBar::setShape ( Shape  s) [virtual]
void QTabBar::setTabEnabled ( int  id,
bool  enabled 
) [virtual]

Enables tab id if enabled is TRUE or disables it if enabled is FALSE. If id is currently selected, setTabEnabled(FALSE) makes another tab selected.

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

Ver también:
update(), isTabEnabled()
virtual void QTabBar::setTabEnabled ( int  ,
bool   
) [virtual]
void QTabBar::setToolTip ( int  index,
const QString tip 
)
void QTabBar::setToolTip ( int  index,
const QString tip 
)

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

Shape QTabBar::shape ( ) const
Shape QTabBar::shape ( ) const
void QTabBar::show ( ) [virtual]

Shows the widget and its child widgets.

If its size or position has changed, Qt guarantees that a widget gets move and resize events just before it is shown.

You almost never have to reimplement this function. If you need to change some settings before a widget is shown, use showEvent() instead. If you need to do some delayed initialization use polish().

Ver también:
showEvent(), hide(), showMinimized(), showMaximized(), showNormal(), isVisible(), polish()

Reimplementado de QWidget.

void QTabBar::show ( ) [virtual]

Reimplementado de QWidget.

QSize QTabBar::sizeHint ( ) const [virtual]

Reimplementado de QWidget.

QSize QTabBar::sizeHint ( ) const [virtual]

Reimplementado de QWidget.

void QTabBar::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 QTabBar::styleChange ( QStyle old) [protected, virtual]

Reimplementado de QWidget.

QTab * QTabBar::tab ( int  id) const

Returns the tab with id id or 0 if there is no such tab.

Ver también:
count()
QTab* QTabBar::tab ( int  ) const
QTab* QTabBar::tabAt ( int  ) const
QTab * QTabBar::tabAt ( int  index) const

Returns the tab at position index.

Ver también:
indexOf()
QPtrList<QTab>* QTabBar::tabList ( ) [protected]
QPtrList< QTab > * QTabBar::tabList ( ) [protected]

The list of QTab objects in the tab bar.

This list is unlikely to be in the order that the QTab elements appear visually. One way of iterating over the tabs is like this:

    for ( uint i = 0; i < myTabBar->count(); ++i ) {
        nextTab = myTabBar->tabAt( i );
        // do something with nextTab
    }
QString QTabBar::toolTip ( int  index) const

Returns the tool tip for the tab at index position index.

QString QTabBar::toolTip ( int  index) const

Documentación de las funciones relacionadas y clases amigas

QTab [friend]
QTabBarToolTip [friend]

Documentación de propiedades

int QTabBar::count [read]

the number of tabs in the tab bar

Ver también:
tab()
int QTabBar::currentTab [read, write]

the id of the tab bar's visible tab

If no tab page is currently visible, the property's value is -1. Even if the property's value is not -1, you cannot assume that the user can see the relevant page, or that the tab is enabled. When you need to display something the value of this property represents the best page to display.

When this property is set to id, it will raise the tab with the id id and emit the selected() signal.

Ver también:
selected() isTabEnabled()
int QTabBar::keyboardFocusTab [read]

the id of the tab that has the keyboard focus

This property contains the id of the tab that has the keyboard focus or -1 if the tab bar does not have the keyboard focus.

Shape QTabBar::shape [read, write]

the shape of the tabs in the tab bar

The value of this property is one of the following: RoundedAbove (default), RoundedBelow, TriangularAbove or TriangularBelow.

Ver también:
Shape

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'