|
|
||||||||||
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.QTabWidget
public class QTabWidget
The QTabWidget class provides a stack of tabbed widgets.
A tab widget provides a tab bar (see QTabBar) and a "page area" that is used to display pages related to each tab. By default, the tab bar is shown above the page area, but different configurations are available (see TabPosition). Each tab is associated with a different widget (called a page). Only the current page is shown in the page area; all the other pages are hidden. The user can show a different page by clicking on its tab or by pressing its Alt+letter shortcut if it has one.
The normal way to use QTabWidget is to do the following:
The position of the tabs is defined by tabPosition, their shape by tabShape.
The signal currentChanged is emitted when the user selects a page.
The current page index is available as currentIndex, the current page widget with currentWidget. You can retrieve a pointer to a page widget with a given index using widget, and can find the index position of a widget with indexOf. Use setCurrentWidget or setCurrentIndex to show a particular page.
You can change a tab's text and icon using setTabText or setTabIcon. A tab and its associated page can be removed with removeTab.
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.
Tab widgets can be a very good way to split up a complex dialog. An alternative is to use a QStackedWidget for which you provide some means of navigating between pages, for example, a QToolBar or a QListWidget.
Most of the functionality in QTabWidget is provided by a QTabBar (at the top, providing the tabs) and a QStackedWidget (most of the area, organizing the individual pages).
![]() | ![]() | ![]() |
A Windows XP style tab widget. | A Macintosh style tab widget. | A Plastique style tab widget. |
Dialog Example
Nested Class Summary | |
---|---|
static class |
QTabWidget.TabPosition
This enum type defines where QTabWidget draws the tab row: |
static class |
QTabWidget.TabShape
This enum type defines the shape of the tabs. |
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.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I> |
Field Summary | |
---|---|
QSignalEmitter.Signal1<java.lang.Integer> |
currentChanged
This signal is emitted whenever the current page index changes. |
Fields inherited from class com.trolltech.qt.gui.QWidget |
---|
customContextMenuRequested |
Constructor Summary | |
---|---|
QTabWidget()
Equivalent to QTabWidget(0). |
|
QTabWidget(QWidget parent)
Constructs a tabbed widget with parent parent. |
Method Summary | |
---|---|
int |
addTab(QWidget widget,
QIcon icon,
java.lang.String label)
Adds a tab with the given widget, icon, and label to the tab widget, and returns the index of the tab in the tab bar. |
int |
addTab(QWidget widget,
java.lang.String arg__2)
Adds a tab with the given widget and arg__2 to the tab widget, and returns the index of the tab in the tab bar. |
protected void |
changeEvent(QEvent arg__1)
This function is reimplemented for internal reasons. |
void |
clear()
Removes all the pages, but does not delete them. |
QWidget |
cornerWidget()
Equivalent to cornerWidget(Qt::TopRightCorner). |
QWidget |
cornerWidget(Qt.Corner corner)
Returns the widget shown in the corner of the tab widget or 0. |
int |
count()
Returns the number of tabs in the tab bar. |
int |
currentIndex()
Returns the index position of the current tab page. |
QWidget |
currentWidget()
Returns a pointer to the page currently being displayed by the tab dialog. |
Qt.TextElideMode |
elideMode()
Returns how to elide text in the tab bar. |
boolean |
event(QEvent arg__1)
This function is reimplemented for internal reasons. |
static QTabWidget |
fromNativePointer(QNativePointer nativePointer)
This function returns the QTabWidget instance pointed to by nativePointer |
QSize |
iconSize()
Returns The size for icons in the tab bar. |
int |
indexOf(QWidget widget)
Returns the index position of the page occupied by the widget widget, or -1 if the widget cannot be found. |
protected void |
initStyleOption(QStyleOptionTabWidgetFrame option)
Initialize option with the values from this QTabWidget. |
int |
insertTab(int index,
QWidget widget,
QIcon icon,
java.lang.String label)
Inserts a tab with the given label, widget, and icon into the tab widget at the specified index, and returns the index of the inserted tab in the tab bar. |
int |
insertTab(int index,
QWidget widget,
java.lang.String arg__3)
Inserts a tab with the given arg__3 and widget into the tab widget at the specified index, and returns the index of the inserted tab in the tab bar. |
boolean |
isTabEnabled(int index)
Returns true if the the page at position index is enabled; otherwise returns false. |
protected void |
keyPressEvent(QKeyEvent arg__1)
This function is reimplemented for internal reasons. |
QSize |
minimumSizeHint()
This function is reimplemented for internal reasons. |
protected void |
paintEvent(QPaintEvent arg__1)
Paints the tab widget's tab bar in response to the paint arg__1. |
void |
removeTab(int index)
Removes the tab at position index from this stack of widgets. |
protected void |
resizeEvent(QResizeEvent arg__1)
This function is reimplemented for internal reasons. |
void |
setCornerWidget(QWidget w)
Equivalent to setCornerWidget(w, Qt::TopRightCorner). |
void |
setCornerWidget(QWidget w,
Qt.Corner corner)
Sets the given w to be shown in the specified corner of the tab widget. |
void |
setCurrentIndex(int index)
Sets the index position of the current tab page to index. |
void |
setCurrentWidget(QWidget widget)
Makes widget the current widget. |
void |
setElideMode(Qt.TextElideMode arg__1)
Sets how to elide text in the tab bar to arg__1. |
void |
setIconSize(QSize size)
Sets The size for icons in the tab bar to size. |
protected void |
setTabBar(QTabBar arg__1)
Replaces the dialog's QTabBar heading with the tab bar arg__1. |
void |
setTabEnabled(int index,
boolean arg__2)
If arg__2 is true, the page at position index is enabled; otherwise the page at position index is disabled. |
void |
setTabIcon(int index,
QIcon icon)
Sets the icon for the tab at position index. |
void |
setTabPosition(QTabWidget.TabPosition arg__1)
Sets the position of the tabs in this tab widget to arg__1. |
void |
setTabShape(QTabWidget.TabShape s)
Sets the shape of the tabs in this tab widget to s. |
void |
setTabText(int index,
java.lang.String arg__2)
Defines a new arg__2 for the page at position index's tab. |
void |
setTabToolTip(int index,
java.lang.String tip)
Sets the tab tool tip for the page at position index to tip. |
void |
setTabWhatsThis(int index,
java.lang.String text)
Sets the What's This help text for the page at position index to text. |
void |
setUsesScrollButtons(boolean useButtons)
Sets Whether or not a tab bar should use buttons to scroll tabs when it has many tabs. |
protected void |
showEvent(QShowEvent arg__1)
This function is reimplemented for internal reasons. |
QSize |
sizeHint()
This function is reimplemented for internal reasons. |
protected QTabBar |
tabBar()
Returns the current QTabBar. |
QIcon |
tabIcon(int index)
Returns the icon for the tab on the page at position index. |
protected void |
tabInserted(int index)
This virtual handler is called after a new tab was added or inserted at position index. |
QTabWidget.TabPosition |
tabPosition()
Returns the position of the tabs in this tab widget. |
protected void |
tabRemoved(int index)
This virtual handler is called after a tab was removed from position index. |
QTabWidget.TabShape |
tabShape()
Returns the shape of the tabs in this tab widget. |
java.lang.String |
tabText(int index)
Returns the label text for the tab on the page at position index. |
java.lang.String |
tabToolTip(int index)
Returns the tab tool tip for the page at position index or an empty string if no tool tip has been set. |
java.lang.String |
tabWhatsThis(int index)
Returns the What's This help text for the page at position index, or an empty string if no help text has been set. |
boolean |
usesScrollButtons()
Returns Whether or not a tab bar should use buttons to scroll tabs when it has many tabs.. |
QWidget |
widget(int index)
Returns the tab page at index position index or 0 if the index is out of range. |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread, timerEvent |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
disconnect, disconnect, signalSender |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Field Detail |
---|
public final QSignalEmitter.Signal1<java.lang.Integer> currentChanged
This signal is emitted whenever the current page index changes. The parameter is the new current page index position.
Constructor Detail |
---|
public QTabWidget()
Equivalent to QTabWidget(0).
public QTabWidget(QWidget parent)
Constructs a tabbed widget with parent parent.
Method Detail |
---|
public final int addTab(QWidget widget, java.lang.String arg__2)
Adds a tab with the given widget and arg__2 to the tab widget, and returns the index of the tab in the tab bar.
If the tab's arg__2 contains an ampersand, the letter following the ampersand is used as a shortcut for the tab, e.g. if the label is "Bro&wse" then Alt+W becomes a shortcut which will move the focus to this tab.
Note: If you call addTab after show, the layout system will try to adjust to the changes in it's widgets hierarchy and may cause flicker. To prevent this, you can set the QWidget::updatesEnabled property to false prior to changes; remember to set the property to true when the changes are done, making the widget receive paint events again.
public final int addTab(QWidget widget, QIcon icon, java.lang.String label)
Adds a tab with the given widget, icon, and label to the tab widget, and returns the index of the tab in the tab bar.
This function is the same as addTab, but with an additional icon.
public final void clear()
Removes all the pages, but does not delete them. Calling this function is equivalent to calling removeTab until the tab widget is empty.
public final QWidget cornerWidget()
Equivalent to cornerWidget(Qt::TopRightCorner).
public final QWidget cornerWidget(Qt.Corner corner)
Returns the widget shown in the corner of the tab widget or 0.
public final int count()
Returns the number of tabs in the tab bar.
public final int currentIndex()
Returns the index position of the current tab page.
public final QWidget currentWidget()
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).
public final Qt.TextElideMode elideMode()
Returns how to elide text in the tab bar.
This property controls how items are elided when there is not enough space to show them for a given tab bar size.
By default the value is style dependant.
public final QSize iconSize()
Returns The size for icons in the tab bar.
The default value is style-dependent. This is the maximum size that the icons will have. Icons are not scaled up if they are of smaller size.
public final int indexOf(QWidget widget)
Returns the index position of the page occupied by the widget widget, or -1 if the widget cannot be found.
public final int insertTab(int index, QWidget widget, java.lang.String arg__3)
Inserts a tab with the given arg__3 and widget into the tab widget at the specified index, and returns the index of the inserted tab in the tab bar.
The label is displayed in the tab and may vary in appearance depending on the configuration of the tab widget.
If the tab's arg__3 contains an ampersand, the letter following the ampersand is used as a shortcut for the tab, e.g. if the label is "Bro&wse" then Alt+W becomes a shortcut which will move the focus to this tab.
If index is out of range, the tab is simply appended. Otherwise it is inserted at the specified position.
If the QTabWidget was empty before this function is called, the new page becomes the current page. Inserting a new tab at an index less than or equal to the current index will increment the current index, but keep the current page.
Note: If you call insertTab after show, the layout system will try to adjust to the changes in it's widgets hierarchy and may cause flicker. To prevent this, you can set the QWidget::updatesEnabled property to false prior to changes; remember to set the property to true when the changes are done, making the widget receive paint events again.
public final int insertTab(int index, QWidget widget, QIcon icon, java.lang.String label)
Inserts a tab with the given label, widget, and icon into the tab widget at the specified index, and returns the index of the inserted tab in the tab bar.
This function is the same as insertTab, but with an additional icon.
public final boolean isTabEnabled(int index)
Returns true if the the page at position index is enabled; otherwise returns false.
public final void removeTab(int index)
Removes the tab at position index from this stack of widgets. The page widget itself is not deleted.
public final void setCornerWidget(QWidget w)
Equivalent to setCornerWidget(w, Qt::TopRightCorner).
public final void setCornerWidget(QWidget w, Qt.Corner corner)
Sets the given w to be shown in the specified corner of the tab widget. The geometry of the widget is determined based on the widget's sizeHint and the style.
Only the horizontal element of the corner will be used.
Passing 0 shows no widget in the corner.
Any previously set corner widget is hidden.
All widgets set here will be deleted by the tab widget when it is destroyed unless you separately reparent the widget after setting some other corner widget (or 0).
Note: Corner widgets are designed for North and South tab positions; other orientations are known to not work properly.
public final void setCurrentIndex(int index)
Sets the index position of the current tab page to index.
public final void setCurrentWidget(QWidget widget)
Makes widget the current widget. The widget used must be a page in this tab widget.
public final void setElideMode(Qt.TextElideMode arg__1)
Sets how to elide text in the tab bar to arg__1.
This property controls how items are elided when there is not enough space to show them for a given tab bar size.
By default the value is style dependant.
public final void setIconSize(QSize size)
Sets The size for icons in the tab bar to size.
The default value is style-dependent. This is the maximum size that the icons will have. Icons are not scaled up if they are of smaller size.
protected final void setTabBar(QTabBar arg__1)
Replaces the dialog's QTabBar heading with the tab bar arg__1. Note that this must be called before any tabs have been added, or the behavior is undefined.
public final void setTabEnabled(int index, boolean arg__2)
If arg__2 is true, the page at position index is enabled; otherwise the page at position index is disabled. The page's tab is redrawn appropriately.
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.
public final void setTabIcon(int index, QIcon icon)
Sets the icon for the tab at position index.
public final void setTabPosition(QTabWidget.TabPosition arg__1)
Sets the position of the tabs in this tab widget to arg__1.
Possible values for this property are described by the TabPosition enum.
public final void setTabShape(QTabWidget.TabShape s)
Sets the shape of the tabs in this tab widget to s.
Possible values for this property are QTabWidget::Rounded (default) or QTabWidget::Triangular.
public final void setTabText(int index, java.lang.String arg__2)
Defines a new arg__2 for the page at position index's tab.
If the provided text contains an ampersand character ('&'), a shortcut is automatically created for it. The character that follows the '&' will be used as the shortcut key. Any previous shortcut will be overwritten, or cleared if no shortcut is defined by the text. See the QShortcut documentation for details (to display an actual ampersand, use '&&').
public final void setTabToolTip(int index, java.lang.String tip)
Sets the tab tool tip for the page at position index to tip.
public final void setTabWhatsThis(int index, java.lang.String text)
Sets the What's This help text for the page at position index to text.
public final void setUsesScrollButtons(boolean useButtons)
Sets Whether or not a tab bar should use buttons to scroll tabs when it has many tabs. to useButtons.
When there are too many tabs in a tab bar for its size, the tab bar can either choose to expand it's size or to add buttons that allow you to scroll through the tabs.
By default the value is style dependant.
protected final QTabBar tabBar()
Returns the current QTabBar.
public final QIcon tabIcon(int index)
Returns the icon for the tab on the page at position index.
public final QTabWidget.TabPosition tabPosition()
Returns the position of the tabs in this tab widget.
Possible values for this property are described by the TabPosition enum.
public final QTabWidget.TabShape tabShape()
Returns the shape of the tabs in this tab widget.
Possible values for this property are QTabWidget::Rounded (default) or QTabWidget::Triangular.
public final java.lang.String tabText(int index)
Returns the label text for the tab on the page at position index.
public final java.lang.String tabToolTip(int index)
Returns the tab tool tip for the page at position index or an empty string if no tool tip has been set.
public final java.lang.String tabWhatsThis(int index)
Returns the What's This help text for the page at position index, or an empty string if no help text has been set.
public final boolean usesScrollButtons()
Returns Whether or not a tab bar should use buttons to scroll tabs when it has many tabs..
When there are too many tabs in a tab bar for its size, the tab bar can either choose to expand it's size or to add buttons that allow you to scroll through the tabs.
By default the value is style dependant.
public final QWidget widget(int index)
Returns the tab page at index position index or 0 if the index is out of range.
protected void changeEvent(QEvent arg__1)
This function is reimplemented for internal reasons.
changeEvent
in class QWidget
public boolean event(QEvent arg__1)
This function is reimplemented for internal reasons.
event
in class QWidget
protected void keyPressEvent(QKeyEvent arg__1)
This function is reimplemented for internal reasons.
keyPressEvent
in class QWidget
public QSize minimumSizeHint()
This function is reimplemented for internal reasons.
minimumSizeHint
in class QWidget
protected void paintEvent(QPaintEvent arg__1)
Paints the tab widget's tab bar in response to the paint arg__1.
paintEvent
in class QWidget
protected void resizeEvent(QResizeEvent arg__1)
This function is reimplemented for internal reasons.
resizeEvent
in class QWidget
Example
protected void showEvent(QShowEvent arg__1)
This function is reimplemented for internal reasons.
showEvent
in class QWidget
visible
,
event,
QShowEventpublic QSize sizeHint()
This function is reimplemented for internal reasons.
sizeHint
in class QWidget
protected void tabInserted(int index)
This virtual handler is called after a new tab was added or inserted at position index.
protected void tabRemoved(int index)
This virtual handler is called after a tab was removed from position index.
public static QTabWidget fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.protected final void initStyleOption(QStyleOptionTabWidgetFrame option)
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |