|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QWidget
com.trolltech.qt.gui.QTabBar
public class QTabBar
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
.
Each tab has a tabText()
, an optional tabIcon()
, an optional tabToolTip()
, optional tabWhatsThis()
and optional tabData()
. The tabs's attributes can be changed with setTabText()
, setTabIcon()
, setTabToolTip()
, setTabWhatsThis
and setTabData()
. Each tabs can be enabled or disabled individually with setTabEnabled()
.
Each tab can display text in a distinct color. The current text color for a tab can be found with the tabTextColor()
function. Set the text color for a particular tab with setTabTextColor()
.
Tabs are added using addTab()
, or inserted at particular positions using insertTab()
. The total number of tabs is given by count()
. Tabs can be removed from the tab bar with removeTab()
. Combining removeTab()
and insertTab()
allows you to move tabs to different positions.
The shape
property defines the tabs' appearance. The choice of shape is a matter of taste, although tab dialogs (for preferences and similar) invariably use RoundedNorth
. Tab controls in windows other than dialogs almost always use either RoundedSouth
or TriangularSouth
. Many spreadsheets and other tab controls in which all the pages are essentially similar use TriangularSouth
, whereas RoundedSouth
is used mostly when the pages are different (e.g. a multi-page tool palette). The default in QTabBar
is RoundedNorth
.
The most important part of QTabBar
's API is the currentChanged()
signal. This is emitted whenever the current tab changes (even at startup, when the current tab changes from 'none'). There is also a slot, setCurrentIndex()
, which can be used to select a tab programmatically. The function currentIndex()
returns the index of the current tab, count
holds the number of tabs.
QTabBar
creates automatic mnemonic keys in the manner of QAbstractButton
; e.g. if a tab's label is "&Graphics", Alt+G becomes a shortcut key for switching to that tab.
The following virtual functions may need to be reimplemented in order to tailor the look and feel or store extra data with each tab:
tabSizeHint()
calcuates the size of a tab.tabInserted()
notifies that a new tab was added.tabRemoved()
notifies that a tab was removed.tabLayoutChange()
notifies that the tabs have been re-laid out.paintEvent()
paints all tabs.tabRect()
functions which returns the visual geometry of a single tab. ![]() | A tab bar shown in the Plastique widget style. |
![]() | A truncated tab bar shown in the Plastique widget style. |
QTabWidget
.
Nested Class Summary | |
---|---|
static class |
QTabBar.Shape
This enum type lists the built-in shapes supported by QTabBar . |
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget |
---|
QWidget.RenderFlag, QWidget.RenderFlags |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Field Summary | |
---|---|
QSignalEmitter.Signal1 |
currentChanged
This signal is emitted when the tab bar's current tab changes. |
Fields inherited from class com.trolltech.qt.gui.QWidget |
---|
customContextMenuRequested |
Constructor Summary | |
---|---|
QTabBar()
Creates a new tab bar with the given parent. |
|
QTabBar(QWidget parent)
Creates a new tab bar with the given parent. |
Method Summary | |
---|---|
int |
addTab(QIcon icon,
java.lang.String text)
Adds a new tab with icon icon and text text. |
int |
addTab(java.lang.String text)
Adds a new tab with text text. |
int |
count()
This property holds the number of tabs in the tab bar. |
int |
currentIndex()
This property holds the index of the tab bar's visible tab. |
boolean |
drawBase()
This property defines whether or not tab bar should draw its base. |
Qt.TextElideMode |
elideMode()
This property holds how to elide text in the tab bar. |
static QTabBar |
fromNativePointer(QNativePointer nativePointer)
|
QSize |
iconSize()
This property holds The size for icons in the tab bar. |
void |
initStyleOption(QStyleOptionTab option,
int tabIndex)
Initialize option with the values from the tab at tabIndex. |
int |
insertTab(int index,
QIcon icon,
java.lang.String text)
Inserts a new tab with icon icon and text text at position index. |
int |
insertTab(int index,
java.lang.String text)
Inserts a new tab with text text at position index. |
boolean |
isTabEnabled(int index)
Returns true if the tab at position index is enabled; otherwise returns false. |
void |
removeTab(int index)
Removes the tab at position index. |
void |
setCurrentIndex(int index)
This property holds the index of the tab bar's visible tab. |
void |
setDrawBase(boolean drawTheBase)
This property defines whether or not tab bar should draw its base. |
void |
setElideMode(Qt.TextElideMode arg__1)
This property holds how to elide text in the tab bar. |
void |
setIconSize(QSize size)
This property holds The size for icons in the tab bar. |
void |
setShape(QTabBar.Shape shape)
This property holds the shape of the tabs in the tab bar. |
void |
setTabData(int index,
java.lang.Object data)
Sets the data of the tab at position index to data. |
void |
setTabEnabled(int index,
boolean arg__2)
If enabled is true then the tab at position index is enabled; otherwise the item at position index is disabled. |
void |
setTabIcon(int index,
QIcon icon)
Sets the icon of the tab at position index to icon. |
void |
setTabText(int index,
java.lang.String text)
Sets the text of the tab at position index to text. |
void |
setTabTextColor(int index,
QColor color)
Sets the color of the text in the tab with the given index to the specified color. |
void |
setTabToolTip(int index,
java.lang.String tip)
Sets the tool tip of the tab at position index to tip. |
void |
setTabWhatsThis(int index,
java.lang.String text)
Sets the What's This help text of the tab at position index to text. |
void |
setUsesScrollButtons(boolean useButtons)
This property holds Whether or not a tab bar should use buttons to scroll tabs when it has many tabs. |
QTabBar.Shape |
shape()
This property holds the shape of the tabs in the tab bar. |
int |
tabAt(QPoint pos)
Returns the index of the tab that covers position or -1 if no tab covers position; |
java.lang.Object |
tabData(int index)
Returns the datad of the tab at position index, or a null variant if index is out of range. |
QIcon |
tabIcon(int index)
Returns the icon of the tab at position index, or a null icon if index is out of range. |
protected void |
tabInserted(int index)
This virtual handler is called after a new tab was added or inserted at position index. |
protected void |
tabLayoutChange()
This virtual handler is called whenever the tab layout changes. |
QRect |
tabRect(int index)
Returns the visual rectangle of the of the tab at position index, or a null rectangle if index is out of range. |
protected void |
tabRemoved(int index)
This virtual handler is called after a tab was removed from position index. |
protected QSize |
tabSizeHint(int index)
Returns the size hint for the tab at position index. |
java.lang.String |
tabText(int index)
Returns the text of the tab at position index, or an empty string if index is out of range. |
QColor |
tabTextColor(int index)
Returns the text color of the tab with the given index, or a invalid color if index is out of range. |
java.lang.String |
tabToolTip(int index)
Returns the tool tip of the tab at position index, or an empty string if index is out of range. |
java.lang.String |
tabWhatsThis(int index)
Returns the What's This help text of the tab at position index, or an empty string if index is out of range. |
boolean |
usesScrollButtons()
This property holds Whether or not a tab bar should use buttons to scroll tabs when it has many tabs. |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Field Detail |
---|
public final QSignalEmitter.Signal1 currentChanged
QTabBar
)
Constructor Detail |
---|
public QTabBar()
public QTabBar(QWidget parent)
Method Detail |
---|
public final int addTab(QIcon icon, java.lang.String text)
public final int addTab(java.lang.String text)
public final int count()
public final int currentIndex()
public final boolean drawBase()
QTabBar
draws a base in relation to the styles overlab. Otherwise only the tabs are drawn. QStyle::pixelMetric()
, QStyle::PM_TabBarBaseOverlap
, and QStyleOptionTabBarBase
.
public final Qt.TextElideMode elideMode()
By default the value is style dependent.
QTabWidget::elideMode
, usesScrollButtons
, and QStyle::SH_TabBar_ElideMode
.
public final QSize iconSize()
QTabWidget::iconSize
.
public final int insertTab(int index, QIcon icon, java.lang.String text)
If the QTabBar
was empty before this function is called, the inserted tab becomes the current tab.
Inserting a new tab at an index less than or equal to the current index will increment the current index, but keep the current tab.
public final int insertTab(int index, java.lang.String text)
public final boolean isTabEnabled(int index)
public final void removeTab(int index)
public final void setCurrentIndex(int index)
public final void setDrawBase(boolean drawTheBase)
QTabBar
draws a base in relation to the styles overlab. Otherwise only the tabs are drawn. QStyle::pixelMetric()
, QStyle::PM_TabBarBaseOverlap
, and QStyleOptionTabBarBase
.
public final void setElideMode(Qt.TextElideMode arg__1)
By default the value is style dependent.
QTabWidget::elideMode
, usesScrollButtons
, and QStyle::SH_TabBar_ElideMode
.
public final void setIconSize(QSize size)
QTabWidget::iconSize
.
public final void setShape(QTabBar.Shape shape)
public final void setTabData(int index, java.lang.Object data)
tabData()
.
public final void setTabEnabled(int index, boolean arg__2)
isTabEnabled()
.
public final void setTabIcon(int index, QIcon icon)
tabIcon()
.
public final void setTabText(int index, java.lang.String text)
tabText()
.
public final void setTabTextColor(int index, QColor color)
If an invalid color is specified, the tab will use the QTabBar
foreground role instead.
tabTextColor()
.
public final void setTabToolTip(int index, java.lang.String tip)
tabToolTip()
.
public final void setTabWhatsThis(int index, java.lang.String text)
tabWhatsThis()
.
public final void setUsesScrollButtons(boolean useButtons)
By default the value is style dependant.
elideMode
, QTabWidget::usesScrollButtons
, and QStyle::SH_TabBar_PreferNoArrows
.
public final QTabBar.Shape shape()
public final int tabAt(QPoint pos)
public final java.lang.Object tabData(int index)
setTabData()
.
public final QIcon tabIcon(int index)
setTabIcon()
.
public final QRect tabRect(int index)
public final java.lang.String tabText(int index)
setTabText()
.
public final QColor tabTextColor(int index)
setTabTextColor()
.
public final java.lang.String tabToolTip(int index)
setTabToolTip()
.
public final java.lang.String tabWhatsThis(int index)
setTabWhatsThis()
.
public final boolean usesScrollButtons()
By default the value is style dependant.
elideMode
, QTabWidget::usesScrollButtons
, and QStyle::SH_TabBar_PreferNoArrows
.
protected void tabInserted(int index)
tabRemoved()
.
protected void tabLayoutChange()
tabRect()
.
protected void tabRemoved(int index)
tabInserted()
.
protected QSize tabSizeHint(int index)
public static QTabBar fromNativePointer(QNativePointer nativePointer)
public final void initStyleOption(QStyleOptionTab option, int tabIndex)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |