QTabBar¶
Synopsis¶
Functions¶
def
accessibleTabName
(index)def
addTab
(icon, text)def
addTab
(text)def
autoHide
()def
changeCurrentOnDrag
()def
count
()def
currentIndex
()def
documentMode
()def
drawBase
()def
elideMode
()def
expanding
()def
iconSize
()def
initStyleOption
(option, tabIndex)def
insertTab
(index, icon, text)def
insertTab
(index, text)def
isMovable
()def
isTabEnabled
(index)def
moveTab
(from, to)def
removeTab
(index)def
selectionBehaviorOnRemove
()def
setAccessibleTabName
(index, name)def
setAutoHide
(hide)def
setChangeCurrentOnDrag
(change)def
setDocumentMode
(set)def
setDrawBase
(drawTheBase)def
setElideMode
(arg__1)def
setExpanding
(enabled)def
setIconSize
(size)def
setMovable
(movable)def
setSelectionBehaviorOnRemove
(behavior)def
setShape
(shape)def
setTabButton
(index, position, widget)def
setTabData
(index, data)def
setTabEnabled
(index, arg__2)def
setTabIcon
(index, icon)def
setTabText
(index, text)def
setTabTextColor
(index, color)def
setTabToolTip
(index, tip)def
setTabWhatsThis
(index, text)def
setTabsClosable
(closable)def
setUsesScrollButtons
(useButtons)def
shape
()def
tabAt
(pos)def
tabButton
(index, position)def
tabData
(index)def
tabIcon
(index)def
tabRect
(index)def
tabText
(index)def
tabTextColor
(index)def
tabToolTip
(index)def
tabWhatsThis
(index)def
tabsClosable
()def
usesScrollButtons
()
Virtual functions¶
def
minimumTabSizeHint
(index)def
tabInserted
(index)def
tabLayoutChange
()def
tabRemoved
(index)def
tabSizeHint
(index)
Slots¶
def
setCurrentIndex
(index)
Signals¶
def
currentChanged
(index)def
tabBarClicked
(index)def
tabBarDoubleClicked
(index)def
tabCloseRequested
(index)def
tabMoved
(from, to)
Detailed Description¶
QTabBar
is straightforward to use; it draws the tabs using one of the predefinedshapes
, and emits a signal when a tab is selected. It can be subclassed to tailor the look and feel. Qt also provides a ready-madeQTabWidget
.Each tab has a
tabText()
, an optionaltabIcon()
, an optionaltabToolTip()
, optionaltabWhatsThis()
and optionaltabData()
. The tabs’s attributes can be changed withsetTabText()
,setTabIcon()
,setTabToolTip()
,setTabWhatsThis
andsetTabData()
. Each tabs can be enabled or disabled individually withsetTabEnabled()
.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 withsetTabTextColor()
.Tabs are added using
addTab()
, or inserted at particular positions usinginsertTab()
. The total number of tabs is given bycount()
. Tabs can be removed from the tab bar withremoveTab()
. CombiningremoveTab()
andinsertTab()
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 useRoundedNorth
. Tab controls in windows other than dialogs almost always use eitherRoundedSouth
orTriangularSouth
. Many spreadsheets and other tab controls in which all the pages are essentially similar useTriangularSouth
, whereasRoundedSouth
is used mostly when the pages are different (e.g. a multi-page tool palette). The default inQTabBar
isRoundedNorth
.The most important part of
QTabBar
‘s API is thecurrentChanged()
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 functioncurrentIndex()
returns the index of the current tab,count
holds the number of tabs.
QTabBar
creates automatic mnemonic keys in the manner ofQAbstractButton
; 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.For subclasses, you might also need the
tabRect()
functions which returns the visual geometry of a single tab.
A tab bar shown in the Fusion widget style .
A truncated tab bar shown in the Fusion widget style.
See also
-
PySide2.QtWidgets.QTabBar.
Shape
¶ This enum type lists the built-in shapes supported by
QTabBar
. Treat these as hints as some styles may not render some of the shapes. However, position should be honored.Constant
Description
QTabBar.RoundedNorth
The normal rounded look above the pages
QTabBar.RoundedSouth
The normal rounded look below the pages
QTabBar.RoundedWest
The normal rounded look on the left side of the pages
QTabBar.RoundedEast
The normal rounded look on the right side the pages
QTabBar.TriangularNorth
Triangular tabs above the pages.
QTabBar.TriangularSouth
Triangular tabs similar to those used in the Excel spreadsheet, for example
QTabBar.TriangularWest
Triangular tabs on the left of the pages.
QTabBar.TriangularEast
Triangular tabs on the right of the pages.
-
PySide2.QtWidgets.QTabBar.
ButtonPosition
¶ This enum type lists the location of the widget on a tab.
Constant
Description
QTabBar.LeftSide
Left side of the tab.
QTabBar.RightSide
Right side of the tab.
-
PySide2.QtWidgets.QTabBar.
SelectionBehavior
¶ This enum type lists the behavior of
QTabBar
when a tab is removed and the tab being removed is also the current tab.Constant
Description
QTabBar.SelectLeftTab
Select the tab to the left of the one being removed.
QTabBar.SelectRightTab
Select the tab to the right of the one being removed.
QTabBar.SelectPreviousTab
Select the previously selected tab.
-
PySide2.QtWidgets.QTabBar.
accessibleTabName
(index)¶ - Parameters
index –
int
- Return type
unicode
Returns the
accessibleName
of the tab at positionindex
, or an empty string ifindex
is out of range.See also
-
PySide2.QtWidgets.QTabBar.
addTab
(icon, text)¶ - Parameters
icon –
QIcon
text – unicode
- Return type
int
This is an overloaded function.
Adds a new tab with icon
icon
and texttext
. Returns the new tab’s index.
-
PySide2.QtWidgets.QTabBar.
addTab
(text) - Parameters
text – unicode
- Return type
int
Adds a new tab with text
text
. Returns the new tab’s index.
-
PySide2.QtWidgets.QTabBar.
autoHide
()¶ - Return type
bool
See also
-
PySide2.QtWidgets.QTabBar.
changeCurrentOnDrag
()¶ - Return type
bool
See also
-
PySide2.QtWidgets.QTabBar.
count
()¶ - Return type
int
-
PySide2.QtWidgets.QTabBar.
currentChanged
(index)¶ - Parameters
index –
int
-
PySide2.QtWidgets.QTabBar.
currentIndex
()¶ - Return type
int
See also
-
PySide2.QtWidgets.QTabBar.
documentMode
()¶ - Return type
bool
See also
-
PySide2.QtWidgets.QTabBar.
drawBase
()¶ - Return type
bool
See also
-
PySide2.QtWidgets.QTabBar.
elideMode
()¶ - Return type
TextElideMode
See also
-
PySide2.QtWidgets.QTabBar.
expanding
()¶ - Return type
bool
See also
-
PySide2.QtWidgets.QTabBar.
iconSize
()¶ - Return type
QSize
See also
-
PySide2.QtWidgets.QTabBar.
initStyleOption
(option, tabIndex)¶ - Parameters
option –
QStyleOptionTab
tabIndex –
int
Initialize
option
with the values from the tab attabIndex
. This method is useful for subclasses when they need aQStyleOptionTab
, but don’t want to fill in all the information themselves.See also
-
PySide2.QtWidgets.QTabBar.
insertTab
(index, icon, text)¶ - Parameters
index –
int
icon –
QIcon
text – unicode
- Return type
int
This is an overloaded function.
Inserts a new tab with icon
icon
and texttext
at positionindex
. Ifindex
is out of range, the new tab is appended. Returns the new tab’s index.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.
-
PySide2.QtWidgets.QTabBar.
insertTab
(index, text) - Parameters
index –
int
text – unicode
- Return type
int
Inserts a new tab with text
text
at positionindex
. Ifindex
is out of range, the new tab is appened. Returns the new tab’s index.
-
PySide2.QtWidgets.QTabBar.
isMovable
()¶ - Return type
bool
-
PySide2.QtWidgets.QTabBar.
isTabEnabled
(index)¶ - Parameters
index –
int
- Return type
bool
Returns
true
if the tab at positionindex
is enabled; otherwise returnsfalse
.
-
PySide2.QtWidgets.QTabBar.
minimumTabSizeHint
(index)¶ - Parameters
index –
int
- Return type
QSize
Returns the minimum tab size hint for the tab at position
index
.
-
PySide2.QtWidgets.QTabBar.
moveTab
(from, to)¶ - Parameters
from –
int
to –
int
Moves the item at index position
from
to index positionto
.See also
-
PySide2.QtWidgets.QTabBar.
removeTab
(index)¶ - Parameters
index –
int
Removes the tab at position
index
.See also
SelectionBehavior
-
PySide2.QtWidgets.QTabBar.
selectionBehaviorOnRemove
()¶ - Return type
See also
-
PySide2.QtWidgets.QTabBar.
setAccessibleTabName
(index, name)¶ - Parameters
index –
int
name – unicode
Sets the
accessibleName
of the tab at positionindex
toname
.See also
-
PySide2.QtWidgets.QTabBar.
setAutoHide
(hide)¶ - Parameters
hide –
bool
See also
-
PySide2.QtWidgets.QTabBar.
setChangeCurrentOnDrag
(change)¶ - Parameters
change –
bool
See also
-
PySide2.QtWidgets.QTabBar.
setCurrentIndex
(index)¶ - Parameters
index –
int
See also
-
PySide2.QtWidgets.QTabBar.
setDocumentMode
(set)¶ - Parameters
set –
bool
See also
-
PySide2.QtWidgets.QTabBar.
setDrawBase
(drawTheBase)¶ - Parameters
drawTheBase –
bool
See also
-
PySide2.QtWidgets.QTabBar.
setElideMode
(arg__1)¶ - Parameters
arg__1 –
TextElideMode
See also
-
PySide2.QtWidgets.QTabBar.
setExpanding
(enabled)¶ - Parameters
enabled –
bool
See also
-
PySide2.QtWidgets.QTabBar.
setIconSize
(size)¶ - Parameters
size –
QSize
See also
-
PySide2.QtWidgets.QTabBar.
setMovable
(movable)¶ - Parameters
movable –
bool
See also
-
PySide2.QtWidgets.QTabBar.
setSelectionBehaviorOnRemove
(behavior)¶ - Parameters
behavior –
SelectionBehavior
See also
-
PySide2.QtWidgets.QTabBar.
setTabButton
(index, position, widget)¶ - Parameters
index –
int
position –
ButtonPosition
widget –
QWidget
Sets
widget
on the tabindex
. The widget is placed on the left or right hand side depending upon theposition
.Any previously set widget in
position
is hidden.The tab bar will take ownership of the widget and so all widgets set here will be deleted by the tab bar when it is destroyed unless you separately reparent the widget after setting some other widget (or 0).
See also
-
PySide2.QtWidgets.QTabBar.
setTabData
(index, data)¶ - Parameters
index –
int
data – object
Sets the data of the tab at position
index
todata
.See also
-
PySide2.QtWidgets.QTabBar.
setTabEnabled
(index, arg__2)¶ - Parameters
index –
int
arg__2 –
bool
If
enabled
is true then the tab at positionindex
is enabled; otherwise the item at positionindex
is disabled.See also
-
PySide2.QtWidgets.QTabBar.
setTabIcon
(index, icon)¶ - Parameters
index –
int
icon –
QIcon
Sets the icon of the tab at position
index
toicon
.See also
-
PySide2.QtWidgets.QTabBar.
setTabText
(index, text)¶ - Parameters
index –
int
text – unicode
Sets the text of the tab at position
index
totext
.See also
-
PySide2.QtWidgets.QTabBar.
setTabTextColor
(index, color)¶ - Parameters
index –
int
color –
QColor
Sets the color of the text in the tab with the given
index
to the specifiedcolor
.If an invalid color is specified, the tab will use the
QTabBar
foreground role instead.See also
-
PySide2.QtWidgets.QTabBar.
setTabToolTip
(index, tip)¶ - Parameters
index –
int
tip – unicode
Sets the tool tip of the tab at position
index
totip
.See also
-
PySide2.QtWidgets.QTabBar.
setTabWhatsThis
(index, text)¶ - Parameters
index –
int
text – unicode
Sets the What’s This help text of the tab at position
index
totext
.See also
-
PySide2.QtWidgets.QTabBar.
setTabsClosable
(closable)¶ - Parameters
closable –
bool
See also
-
PySide2.QtWidgets.QTabBar.
setUsesScrollButtons
(useButtons)¶ - Parameters
useButtons –
bool
See also
-
PySide2.QtWidgets.QTabBar.
shape
()¶ - Return type
See also
-
PySide2.QtWidgets.QTabBar.
tabAt
(pos)¶ - Parameters
pos –
QPoint
- Return type
int
Returns the index of the tab that covers
position
or -1 if no tab coversposition
;
-
PySide2.QtWidgets.QTabBar.
tabBarClicked
(index)¶ - Parameters
index –
int
-
PySide2.QtWidgets.QTabBar.
tabBarDoubleClicked
(index)¶ - Parameters
index –
int
-
PySide2.QtWidgets.QTabBar.
tabButton
(index, position)¶ - Parameters
index –
int
position –
ButtonPosition
- Return type
Returns the widget set a tab
index
andposition
or 0 if one is not set.See also
-
PySide2.QtWidgets.QTabBar.
tabCloseRequested
(index)¶ - Parameters
index –
int
-
PySide2.QtWidgets.QTabBar.
tabData
(index)¶ - Parameters
index –
int
- Return type
object
Returns the data of the tab at position
index
, or a null variant ifindex
is out of range.See also
-
PySide2.QtWidgets.QTabBar.
tabIcon
(index)¶ - Parameters
index –
int
- Return type
QIcon
Returns the icon of the tab at position
index
, or a null icon ifindex
is out of range.See also
-
PySide2.QtWidgets.QTabBar.
tabInserted
(index)¶ - Parameters
index –
int
This virtual handler is called after a new tab was added or inserted at position
index
.See also
-
PySide2.QtWidgets.QTabBar.
tabLayoutChange
()¶ This virtual handler is called whenever the tab layout changes.
See also
-
PySide2.QtWidgets.QTabBar.
tabMoved
(from, to)¶ - Parameters
from –
int
to –
int
-
PySide2.QtWidgets.QTabBar.
tabRect
(index)¶ - Parameters
index –
int
- Return type
QRect
Returns the visual rectangle of the tab at position
index
, or a null rectangle ifindex
is out of range.
-
PySide2.QtWidgets.QTabBar.
tabRemoved
(index)¶ - Parameters
index –
int
This virtual handler is called after a tab was removed from position
index
.See also
-
PySide2.QtWidgets.QTabBar.
tabSizeHint
(index)¶ - Parameters
index –
int
- Return type
QSize
Returns the size hint for the tab at position
index
.
-
PySide2.QtWidgets.QTabBar.
tabText
(index)¶ - Parameters
index –
int
- Return type
unicode
Returns the text of the tab at position
index
, or an empty string ifindex
is out of range.See also
-
PySide2.QtWidgets.QTabBar.
tabTextColor
(index)¶ - Parameters
index –
int
- Return type
QColor
Returns the text color of the tab with the given
index
, or a invalid color ifindex
is out of range.See also
-
PySide2.QtWidgets.QTabBar.
tabToolTip
(index)¶ - Parameters
index –
int
- Return type
unicode
Returns the tool tip of the tab at position
index
, or an empty string ifindex
is out of range.See also
-
PySide2.QtWidgets.QTabBar.
tabWhatsThis
(index)¶ - Parameters
index –
int
- Return type
unicode
Returns the What’s This help text of the tab at position
index
, or an empty string ifindex
is out of range.See also
-
PySide2.QtWidgets.QTabBar.
tabsClosable
()¶ - Return type
bool
See also
-
PySide2.QtWidgets.QTabBar.
usesScrollButtons
()¶ - Return type
bool
See also
© 2018 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.