TQTabBar 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. TQt also provides a ready-made TQTabWidget and a TQTabDialog.
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 TQTabBar'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.
TQTabBar creates automatic accelerator keys in the manner of TQButton; 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:
.TP
paint() paints a single tab. paintEvent() calls paint() for each tab so that any overlap will look right.
.TP
addTab() creates a new tab and adds it to the bar.
.TP
selectTab() decides which tab, if any, the user selects with the mouse.
.PP
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.
Sets \fInewTab\fR'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.
Inserts the tab, \fInewTab\fR, into the tab control.
.PP
If \fIindex\fR is not specified, the tab is simply appended. Otherwise it's inserted at the specified position.
.PP
Sets \fInewTab\fR'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.
This virtual function may be reimplemented to change the look of TQTabBar. If you decide to reimplement it, you may also need to reimplement sizeHint().
.SH "void TQTabBar::paintEvent ( TQPaintEvent * e )\fC [virtual protected]\fR"
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 \fIe\fR.
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 \fIp\fR, if exactly one tab's bounding rectangle contains \fIp\fR. Otherwise it returns 0.
.PP
See also mousePressEvent() and mouseReleaseEvent().
.SH "void TQTabBar::selected ( int id )\fC [signal]\fR"
TQTabBar emits this signal whenever any tab is selected, whether by the program or by the user. The argument \fIid\fR is the id of the tab as returned by addTab().
Enables tab \fIid\fR if \fIenabled\fR is TRUE or disables it if \fIenabled\fR is FALSE. If \fIid\fR is currently selected, setTabEnabled(FALSE) makes another tab selected.
.PP
setTabEnabled() updates the display if this causes a change in \fIid\fR's status.
Returns the tool tip for the tab at index position \fIindex\fR.
.SS "Property Documentation"
.SH "int count"
This property holds the number of tabs in the tab bar.
.PP
Get this property's value with count().
.PP
See also tab().
.SH "int currentTab"
This property holds the id of the tab bar's visible tab.
.PP
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.
.PP
When this property is set to \fIid\fR, it will raise the tab with the id \fIid\fR and emit the selected() signal.
.PP
See also selected() and isTabEnabled().
.PP
Set this property's value with setCurrentTab() and get this property's value with currentTab().
.SH "int keyboardFocusTab"
This property holds the id of the tab that has the keyboard focus.
.PP
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.
.PP
Get this property's value with keyboardFocusTab().
.SH "Shape shape"
This property holds the shape of the tabs in the tab bar.
.PP
The value of this property is one of the following: RoundedAbove (default), RoundedBelow, TriangularAbove or TriangularBelow.
.PP
See also Shape.
.PP
Set this property's value with setShape() and get this property's value with shape().