The QTabBar class provides a tab bar, for use in e.g. tabbed dialogs. More...
#include <qtabbar.h>
Inherits QWidget.
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.
The four possible shapes are
RoundedAbove
- (the
default) rounded tabs to be located above the pages. RoundedBelow
- rounded tabs to be located below the pages. TriangularAbove
- triangular tabs to be located above the pages
(very unusual, included for completeness). TriangularBelow
- triangular tabs to be located below the pages. The choice of tab shape is still a matter of taste, to a large
degree. Tab dialogs (preferences and the like) invariable 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:
Create a new, empty tab bar.
Delete the tab control and free the memory it used.
[virtual]
Add newTab to the tab control.
Allocate a new id, set t's id, locate it just to the right of the existing tabs, insert an accelerator if the tab's label contains the string "&p" for some value of p, add it to the bar, and return the newly allocated id.
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().
Return TRUE if the tab with id id is enabled, or FALSE if it is disabled or there is no such tab.
See also: setTabEnabled().
[virtual protected]
Handles the tab bar's keyboard interface (if enabled).
The right and left arrow keys move a selector, the space bar makes the tab with the selector active. All other keys are ignored.
Reimplemented from QWidget.
If this tab control has keyboard focus, returns the ID of the tab Space will select. Otherwise, returns -1.
[virtual protected]
Handles mouse press events; records what tab the mouse points to.
Reimplemented from QWidget.
[virtual protected]
Handles mouse release events for the tab control. Checks that the mouse is released over the tab where it was pressed, and if it was, selects that tab.
Reimplemented from QWidget.
[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().
[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.
[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().
[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.
[slot]
"Raises" tab and emits the selected() signal unless the tab was already current.
See also: currentTab() and selected().
[slot]
"Raises" the tab with ID id and emits the selected() signal.
See also: currentTab(), selected() and tab().
Sets the shape of this tab bar to s and refreshes the bar.
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() calls repaint() if this causes a change in id's status.
See also: update() and isTabEnabled().
Returns the shape of this tab bar.
See also: setShape().
[virtual]
Shows the widget, and ensures that one tab is selected.
Reimplemented from QWidget.
[virtual]
Returns a suitable size for the tab control.
Reimplemented from QWidget.
Returns a pointer to the tab with ID id, or 0 if there is no such tab.
[protected]
The list of QTab objects added.
Search the documentation, FAQ, qt-interest archive and more (uses
www.troll.no):
This file is part of the Qt toolkit, copyright © 1995-98 Troll Tech, all rights reserved.
It was generated from the following files:
Copyright İ 1998 Troll Tech | Trademarks | Qt version 1.42
|