TQTabWidget(3qt)

NAME
TQTabWidget - Stack of tabbed widgets

SYNOPSIS
#include <tqtabwidget.h>

Inherits TQWidget.

  Public Members
TQTabWidget ( TQWidget * parent = 0, const char * name = 0, WFlags f = 0 )
virtual void addTab ( TQWidget * child, const TQString & label )
virtual void addTab ( TQWidget * child, const TQIconSet & iconset, const TQString & label )
virtual void addTab ( TQWidget * child, TQTab * tab )
virtual void insertTab ( TQWidget * child, const TQString & label, int index = -1 )
virtual void insertTab ( TQWidget * child, const TQIconSet & iconset, const TQString & label, int index = -1 )
virtual void insertTab ( TQWidget * child, TQTab * tab, int index = -1 )
void changeTab ( TQWidget * w, const TQString & label )
void changeTab ( TQWidget * w, const TQIconSet & iconset, const TQString & label )
bool isTabEnabled ( TQWidget * w ) const
void setTabEnabled ( TQWidget * w, bool enable )
void setCornerWidget ( TQWidget * w, TQt::Corner corner = TQt::TopRight )
TQWidget * cornerWidget ( TQt::Corner corner = TQt::TopRight ) const
TQString tabLabel ( TQWidget * w ) const
void setTabLabel ( TQWidget * w, const TQString & l )
TQIconSet tabIconSet ( TQWidget * w ) const
void setTabIconSet ( TQWidget * w, const TQIconSet & iconset )
void removeTabToolTip ( TQWidget * w )
void setTabToolTip ( TQWidget * w, const TQString & tip )
TQString tabToolTip ( TQWidget * w ) const
TQWidget * currentPage () const
TQWidget * page ( int index ) const
TQString label ( int index ) const
int currentPageIndex () const
int indexOf ( TQWidget * w ) const
enum TabPosition { Top, Bottom }
TabPosition tabPosition () const
void setTabPosition ( TabPosition )
enum TabShape { Rounded, Triangular }
TabShape tabShape () const
void setTabShape ( TabShape s )
int margin () const
void setMargin ( int )
int count () const

  Public Slots
void setCurrentPage ( int )
virtual void showPage ( TQWidget * w )
virtual void removePage ( TQWidget * w )

  Signals
void currentChanged ( TQWidget * )

  Properties
bool autoMask - whether the tab widget is automatically masked (read only)
int count - the number of tabs in the tab bar (read only)
int currentPage - the index position of the current tab page
int margin - the margin in this tab widget
TabPosition tabPosition - the position of the tabs in this tab widget
TabShape tabShape - the shape of the tabs in this tab widget

  Protected Members
void setTabBar ( TQTabBar * tb )
TQTabBar * tabBar () const

DESCRIPTION
The TQTabWidget 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 TQTabWidget is to do the following in the constructor: <ol type=1>

1   Create a TQTabWidget.

2   Create a TQWidget 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.

3   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 TQTabWidget is already visible, then the page you have created will not be visible. Don't confuse the object name you supply to the TQWidget 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 TQTabDialog for some design hints. An alternative is to use a TQWidgetStack for which you provide some means of navigating between pages, for example, a TQToolBar or a TQListBox.

Most of the functionality in TQTabWidget is provided by a TQTabBar (at the top, providing the tabs) and a TQWidgetStack (most of the area, organizing the individual pages).

[Image Omitted]

[Image Omitted]

See also TQTabDialog, TQToolBox, Advanced Widgets, and Organizers.

  Member Type Documentation

TQTabWidget::TabPosition
This enum type defines where TQTabWidget draws the tab row:

TQTabWidget::Top - above the pages

TQTabWidget::Bottom - below the pages

TQTabWidget::TabShape
This enum type defines the shape of the tabs:

TQTabWidget::Rounded - rounded look (normal)

TQTabWidget::Triangular - triangular look (very unusual, included for completeness)

MEMBER FUNCTION DOCUMENTATION

TQTabWidget::TQTabWidget ( TQWidget * parent = 0, const char * name = 0, WFlags f = 0 )
Constructs a tabbed widget called name with parent parent, and widget flags f.

void TQTabWidget::addTab ( TQWidget * child, const TQString & 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.

See also insertTab().

Examples:

void TQTabWidget::addTab ( TQWidget * child, const TQIconSet & iconset, const TQString & label ) [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Adds another tab and page to the tab view.

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

void TQTabWidget::addTab ( TQWidget * child, TQTab * tab ) [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

This is a low-level function for adding tabs. It is useful if you are using setTabBar() to set a TQTabBar subclass with an overridden TQTabBar::paint() function for a subclass of TQTab. The child is the new page and tab is the tab to put the child on.

void TQTabWidget::changeTab ( TQWidget * w, const TQString & label )
Defines a new label for page w's tab.

void TQTabWidget::changeTab ( TQWidget * w, const TQIconSet & iconset, const TQString & label )
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Defines a new iconset and a new label for page w's tab.

TQWidget * TQTabWidget::cornerWidget ( TQt::Corner corner = TQt::TopRight ) const
Returns the widget shown in the corner of the tab widget or 0.

int TQTabWidget::count () const
Returns the number of tabs in the tab bar. See the "count" property for details.

void TQTabWidget::currentChanged ( TQWidget * ) [signal]
This signal is emitted whenever the current page changes. The parameter is the new current page.

See also currentPage(), showPage(), and tabLabel().

TQWidget * TQTabWidget::currentPage () const
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).

int TQTabWidget::currentPageIndex () const
Returns the index position of the current tab page. See the "currentPage" property for details.

int TQTabWidget::indexOf ( TQWidget * w ) const
Returns the index position of page w, or -1 if the widget cannot be found.

void TQTabWidget::insertTab ( TQWidget * child, const TQString & 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.

See also addTab().

void TQTabWidget::insertTab ( TQWidget * child, const TQIconSet & iconset, const TQString & label, int index = -1 ) [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Inserts another tab and page to the tab view.

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

void TQTabWidget::insertTab ( TQWidget * child, TQTab * tab, int index = -1 ) [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

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 TQTabBar subclass with an overridden TQTabBar::paint() function for a subclass of TQTab. 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.

bool TQTabWidget::isTabEnabled ( TQWidget * w ) const
Returns true if the page w is enabled; otherwise returns false.

See also setTabEnabled() and TQWidget::enabled.

TQString TQTabWidget::label ( int index ) const
Returns the label of the tab at index position index or TQString::null if the index is out of range.

int TQTabWidget::margin () const
Returns the margin in this tab widget. See the "margin" property for details.

TQWidget * TQTabWidget::page ( int index ) const
Returns the tab page at index position index or 0 if the index is out of range.

void TQTabWidget::removePage ( TQWidget * w ) [virtual slot]
Removes page w from this stack of widgets. Does not delete w.

See also addTab(), showPage(), and TQWidgetStack::removeWidget().

void TQTabWidget::removeTabToolTip ( TQWidget * w )
Removes the tab tool tip for page w. If the page does not have a tip, nothing happens.

See also setTabToolTip() and tabToolTip().

void TQTabWidget::setCornerWidget ( TQWidget * w, TQt::Corner corner = TQt::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.

See also cornerWidget() and tabPosition.

void TQTabWidget::setCurrentPage ( int ) [slot]
Sets the index position of the current tab page. See the "currentPage" property for details.

void TQTabWidget::setMargin ( int )
Sets the margin in this tab widget. See the "margin" property for details.

void TQTabWidget::setTabBar ( TQTabBar * tb ) [protected]
Replaces the dialog's TQTabBar heading with the tab bar tb. Note that this must be called before any tabs have been added, or the behavior is undefined.

See also tabBar().

void TQTabWidget::setTabEnabled ( TQWidget * w, bool enable )
If enable is true, page w is enabled; otherwise page w is disabled. The page's tab is redrawn appropriately.

TQTabWidget uses TQWidget::setEnabled() internally, rather than keeping a separate flag.

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

See also isTabEnabled() and TQWidget::enabled.

void TQTabWidget::setTabIconSet ( TQWidget * w, const TQIconSet & iconset )
Sets the iconset for page w to iconset.

void TQTabWidget::setTabLabel ( TQWidget * w, const TQString & l )
Sets the tab label for page w to l

void TQTabWidget::setTabPosition ( TabPosition )
Sets the position of the tabs in this tab widget. See the "tabPosition" property for details.

void TQTabWidget::setTabShape ( TabShape s )
Sets the shape of the tabs in this tab widget to s. See the "tabShape" property for details.

void TQTabWidget::setTabToolTip ( TQWidget * w, const TQString & tip )
Sets the tab tool tip for page w to tip.

See also removeTabToolTip() and tabToolTip().

void TQTabWidget::showPage ( TQWidget * w ) [virtual slot]
Ensures that page w is shown. This is useful mainly for accelerators.

Warning: Used carelessly, this function can easily surprise or confuse the user.

See also TQTabBar::currentTab.

TQTabBar * TQTabWidget::tabBar () const [protected]
Returns the current TQTabBar.

See also setTabBar().

TQIconSet TQTabWidget::tabIconSet ( TQWidget * 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.

TQString TQTabWidget::tabLabel ( TQWidget * w ) const
Returns the label text for the tab on page w.

TabPosition TQTabWidget::tabPosition () const
Returns the position of the tabs in this tab widget. See the "tabPosition" property for details.

TabShape TQTabWidget::tabShape () const
Returns the shape of the tabs in this tab widget. See the "tabShape" property for details.

TQString TQTabWidget::tabToolTip ( TQWidget * w ) const
Returns the tab tool tip for page w or TQString::null if no tool tip has been set.

See also setTabToolTip() and removeTabToolTip().

  Property Documentation

bool autoMask
This property holds whether the tab widget is automatically masked.

See also TQWidget::autoMask.

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

Get this property's value with count().

int currentPage
This property holds the index position of the current tab page.

Set this property's value with setCurrentPage() and get this property's value with currentPageIndex().

See also TQTabBar::currentTab.

int margin
This property holds 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.

Set this property's value with setMargin() and get this property's value with margin().

TabPosition tabPosition
This property holds the position of the tabs in this tab widget.

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

See also TabPosition.

Set this property's value with setTabPosition() and get this property's value with tabPosition().

TabShape tabShape
This property holds the shape of the tabs in this tab widget.

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

See also TabShape.

Set this property's value with setTabShape() and get this property's value with tabShape().

SEE ALSO
http://doc.trolltech.com/tqtabwidget.html http://www.trolltech.com/faq/tech.html

COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.

BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you.

The definitive TQt documentation is provided in HTML format; it is located at $TQTDIR/doc/html and can be read using TQt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (tqtabwidget.3qt) and the Qt version (3.3.8).