|
|
Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The QTabWidget class provides a stack of tabbed widgets. More...
#include <qtabwidget.h>
Inherits QWidget.
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:
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).
See also QTabDialog, QToolBox, Advanced Widgets, and Organizers.
This enum type defines where QTabWidget draws the tab row:
This enum type defines the shape of the tabs:
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: addressbook/centralwidget.cpp and themes/themes.cpp.
Adds another tab and page to the tab view.
This function is the same as addTab(), but with an additional iconset.
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.
Defines a new iconset and a new label for page w's tab.
Returns the number of tabs in the tab bar. See the "count" property for details.
This signal is emitted whenever the current page changes. The parameter is the new current page.
See also currentPage(), showPage(), and tabLabel().
Returns the index position of the current tab page. See the "currentPage" property for details.
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().
Inserts another tab and page to the tab view.
This function is the same as insertTab(), but with an additional iconset.
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.
See also setTabEnabled() and QWidget::enabled.
Returns the margin in this tab widget. See the "margin" property for details.
See also addTab(), showPage(), and QWidgetStack::removeWidget().
See also setTabToolTip() and tabToolTip().
Only the horizontal element of the corner will be used.
See also cornerWidget() and tabPosition.
Sets the index position of the current tab page. See the "currentPage" property for details.
Sets the margin in this tab widget. See the "margin" property for details.
See also tabBar().
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.
See also isTabEnabled() and QWidget::enabled.
Sets the position of the tabs in this tab widget. See the "tabPosition" property for details.
Sets the shape of the tabs in this tab widget to s. See the "tabShape" property for details.
See also removeTabToolTip() and tabToolTip().
Warning: Used carelessly, this function can easily surprise or confuse the user.
See also QTabBar::currentTab.
See also setTabBar().
Returns the position of the tabs in this tab widget. See the "tabPosition" property for details.
Returns the shape of the tabs in this tab widget. See the "tabShape" property for details.
See also setTabToolTip() and removeTabToolTip().
This property holds whether the tab widget is automatically masked.
See also QWidget::autoMask.
This property holds the number of tabs in the tab bar.
Get this property's value with count().
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 QTabBar::currentTab.
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().
This property holds the position of the tabs in this tab widget.
Possible values for this property are QTabWidget::Top and QTabWidget::Bottom.
See also TabPosition.
Set this property's value with setTabPosition() and get this property's value with tabPosition().
This property holds the shape of the tabs in this tab widget.
Possible values for this property are QTabWidget::Rounded (default) or QTabWidget::Triangular.
See also TabShape.
Set this property's value with setTabShape() and get this property's value with tabShape().
This file is part of the Qt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.
Copyright © 2007 Trolltech | Trademarks | Qt 3.3.8
|