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
isTabVisible
(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
(mode)
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, enabled)
def
setTabIcon
(index, icon)
def
setTabText
(index, text)
def
setTabTextColor
(index, color)
def
setTabToolTip
(index, tip)
def
setTabVisible
(index, visible)
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
()
def
minimumTabSizeHint
(index)
def
tabInserted
(index)
def
tabLayoutChange
()
def
tabRemoved
(index)
def
tabSizeHint
(index)
def
setCurrentIndex
(index)
def
currentChanged
(index)
def
tabBarClicked
(index)
def
tabBarDoubleClicked
(index)
def
tabCloseRequested
(index)
def
tabMoved
(from, to)
QTabBaris straightforward to use; it draws the tabs using one of the predefinedshapes,并发射信号,当选项卡被选中时。它可以被子类化以订制外观和感觉。Qt 还提供现成QTabWidget.每个选项卡有
tabText(), an optionaltabIcon(), an optionaltabToolTip(), optionaltabWhatsThis()和可选tabData(). The tabs’s attributes can be changed withsetTabText(),setTabIcon(),setTabToolTip(),setTabWhatsThisandsetTabData(). Each tabs can be enabled or disabled individually withsetTabEnabled().每个选项卡可以按截然不同颜色显示文本。可以找到当前选项卡的文本颜色采用
tabTextColor()function. Set the text color for a particular tab withsetTabTextColor().添加选项卡使用
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.
shapeproperty 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 eitherRoundedSouthorTriangularSouth. Many spreadsheets and other tab controls in which all the pages are essentially similar useTriangularSouth,而RoundedSouthis used mostly when the pages are different (e.g. a multi-page tool palette). The default inQTabBarisRoundedNorth.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,countholds the number of tabs.
QTabBarcreates 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.对于子类,可能还需要
tabRect()functions which returns the visual geometry of a single tab.
![]()
选项卡栏展示在 融合 Widget 风格 .
![]()
以 Fusion 小部件样式展示截取选项卡栏。
另请参阅
PySide2.QtWidgets.QTabBar.
形状
¶
此枚举类型列出了受支持的内置形状,由
QTabBar
. Treat these as hints as some styles may not render some of the shapes. However, position should be honored.
|
常量 |
描述 |
|---|---|
|
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 |
在页面上方的三角形选项卡。 |
|
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
¶
此枚举类型列表 Widget 在选项卡上的位置。
|
常量 |
描述 |
|---|---|
|
QTabBar.LeftSide |
选项卡的左侧。 |
|
QTabBar.RightSide |
选项卡的右侧。 |
PySide2.QtWidgets.QTabBar.
SelectionBehavior
¶
此枚举类型列表行为在
QTabBar
当选项卡被移除且被移除选项卡也是当前选项卡时。
|
常量 |
描述 |
|---|---|
|
QTabBar.SelectLeftTab |
选择被移除选项卡左侧的选项卡。 |
|
QTabBar.SelectRightTab |
选择被移除选项卡右侧的选项卡。 |
|
QTabBar.SelectPreviousTab |
选择先前选中的选项卡。 |
PySide2.QtWidgets.QTabBar.
accessibleTabName
(
index
)
¶
index
–
int
unicode
返回
accessibleName
对于选项卡在位置
index
,或空字符串若
index
超出范围。
PySide2.QtWidgets.QTabBar.
addTab
(
icon
,
text
)
¶
icon
–
QIcon
text – unicode
int
这是重载函数。
添加新选项卡采用图标
icon
和文本
text
. Returns the new tab’s index.
PySide2.QtWidgets.QTabBar.
addTab
(
text
)
¶
text – unicode
int
添加新选项卡采用文本
text
. Returns the new tab’s index.
PySide2.QtWidgets.QTabBar.
autoHide
(
)
¶
bool
另请参阅
PySide2.QtWidgets.QTabBar.
changeCurrentOnDrag
(
)
¶
bool
PySide2.QtWidgets.QTabBar.
count
(
)
¶
int
PySide2.QtWidgets.QTabBar.
currentChanged
(
index
)
¶
index
–
int
PySide2.QtWidgets.QTabBar.
currentIndex
(
)
¶
int
另请参阅
PySide2.QtWidgets.QTabBar.
documentMode
(
)
¶
bool
另请参阅
PySide2.QtWidgets.QTabBar.
drawBase
(
)
¶
bool
另请参阅
PySide2.QtWidgets.QTabBar.
elideMode
(
)
¶
TextElideMode
另请参阅
PySide2.QtWidgets.QTabBar.
expanding
(
)
¶
bool
另请参阅
PySide2.QtWidgets.QTabBar.
iconSize
(
)
¶
QSize
另请参阅
PySide2.QtWidgets.QTabBar.
initStyleOption
(
option
,
tabIndex
)
¶
option
–
QStyleOptionTab
tabIndex
–
int
初始化
option
采用值从选项卡在
tabIndex
。此方法对子类是有用的,当需要
QStyleOptionTab
, but don’t want to fill in all the information themselves.
PySide2.QtWidgets.QTabBar.
insertTab
(
index
,
icon
,
text
)
¶
index
–
int
icon
–
QIcon
text – unicode
int
这是重载函数。
插入新选项卡采用图标
icon
和文本
text
在位置
index
。若
index
is out of range, the new tab is appended. Returns the new tab’s index.
若
QTabBar
为空在调用此函数之前,插入选项卡变为当前选项卡。
在 <= 当前索引的索引处插入新选项卡将递增当前索引,但保持当前选项卡。
PySide2.QtWidgets.QTabBar.
insertTab
(
index
,
text
)
¶
index
–
int
text – unicode
int
插入新选项卡采用文本
text
在位置
index
。若
index
is out of range, the new tab is appened. Returns the new tab’s index.
PySide2.QtWidgets.QTabBar.
isMovable
(
)
¶
bool
PySide2.QtWidgets.QTabBar.
isTabEnabled
(
index
)
¶
index
–
int
bool
返回
true
若选项卡在位置
index
被启用;否则返回
false
.
PySide2.QtWidgets.QTabBar.
isTabVisible
(
index
)
¶
index
–
int
bool
返回 true 若选项卡在位置
index
可见;否则返回 false。
PySide2.QtWidgets.QTabBar.
minimumTabSizeHint
(
index
)
¶
index
–
int
QSize
返回最小选项卡尺寸提示,对于选项卡在位置
index
.
PySide2.QtWidgets.QTabBar.
moveTab
(
from
,
to
)
¶
from
–
int
to
–
int
移动索引位置项
from
到索引位置
to
.
PySide2.QtWidgets.QTabBar.
removeTab
(
index
)
¶
index
–
int
移除选项卡,在位置
index
.
另请参阅
SelectionBehavior
PySide2.QtWidgets.QTabBar.
selectionBehaviorOnRemove
(
)
¶
PySide2.QtWidgets.QTabBar.
setAccessibleTabName
(
index
,
name
)
¶
index
–
int
name – unicode
设置
accessibleName
对于选项卡在位置
index
to
name
.
另请参阅
PySide2.QtWidgets.QTabBar.
setAutoHide
(
hide
)
¶
hide
–
bool
另请参阅
PySide2.QtWidgets.QTabBar.
setChangeCurrentOnDrag
(
change
)
¶
change
–
bool
PySide2.QtWidgets.QTabBar.
setCurrentIndex
(
index
)
¶
index
–
int
另请参阅
PySide2.QtWidgets.QTabBar.
setDocumentMode
(
set
)
¶
set
–
bool
另请参阅
PySide2.QtWidgets.QTabBar.
setDrawBase
(
drawTheBase
)
¶
drawTheBase
–
bool
另请参阅
PySide2.QtWidgets.QTabBar.
setElideMode
(
mode
)
¶
mode
–
TextElideMode
另请参阅
PySide2.QtWidgets.QTabBar.
setExpanding
(
enabled
)
¶
enabled
–
bool
另请参阅
PySide2.QtWidgets.QTabBar.
setIconSize
(
size
)
¶
size
–
QSize
另请参阅
PySide2.QtWidgets.QTabBar.
setMovable
(
movable
)
¶
movable
–
bool
另请参阅
PySide2.QtWidgets.QTabBar.
setSelectionBehaviorOnRemove
(
behavior
)
¶
behavior
–
SelectionBehavior
PySide2.QtWidgets.QTabBar.
setTabButton
(
index
,
position
,
widget
)
¶
index
–
int
position
–
ButtonPosition
widget
–
QWidget
集
widget
在选项卡
index
。Widget 被放置在左侧或右侧从属
position
.
任何先前设置 Widget 在
position
被隐藏。
选项卡栏将拥有小部件的所有权,因此,选项卡栏会删除此处设置的所有小部件当销毁时,除非单独重设 Widget 父级在设置一些其它小部件后 (或
None
).
PySide2.QtWidgets.QTabBar.
setTabData
(
index
,
data
)
¶
index
–
int
data – object
设置选项卡的数据,在位置
index
to
data
.
另请参阅
PySide2.QtWidgets.QTabBar.
setTabEnabled
(
index
,
enabled
)
¶
index
–
int
enabled
–
bool
若
enabled
为 true 则选项卡在位置
index
被启用;否则项在位置
index
是禁用的。
另请参阅
PySide2.QtWidgets.QTabBar.
setTabIcon
(
index
,
icon
)
¶
index
–
int
icon
–
QIcon
设置选项卡的图标,在位置
index
to
icon
.
另请参阅
PySide2.QtWidgets.QTabBar.
setTabText
(
index
,
text
)
¶
index
–
int
text – unicode
设置选项卡的文本,在位置
index
to
text
.
另请参阅
PySide2.QtWidgets.QTabBar.
setTabTextColor
(
index
,
color
)
¶
index
–
int
color
–
QColor
设置选项卡文本颜色采用给定
index
到指定
color
.
如果指定的是无效颜色,选项卡将使用
QTabBar
前景角色代替。
另请参阅
PySide2.QtWidgets.QTabBar.
setTabToolTip
(
index
,
tip
)
¶
index
–
int
tip – unicode
设置选项卡的工具提示,在位置
index
to
tip
.
另请参阅
PySide2.QtWidgets.QTabBar.
setTabVisible
(
index
,
visible
)
¶
index
–
int
visible
–
bool
若
visible
为 true,使选项卡在位置
index
可见,否则使之隐藏。
另请参阅
PySide2.QtWidgets.QTabBar.
setTabWhatsThis
(
index
,
text
)
¶
index
–
int
text – unicode
Sets the What’s This help text of the tab at position
index
to
text
.
另请参阅
PySide2.QtWidgets.QTabBar.
setTabsClosable
(
closable
)
¶
closable
–
bool
另请参阅
PySide2.QtWidgets.QTabBar.
setUsesScrollButtons
(
useButtons
)
¶
useButtons
–
bool
另请参阅
PySide2.QtWidgets.QTabBar.
shape
(
)
¶
另请参阅
PySide2.QtWidgets.QTabBar.
tabAt
(
pos
)
¶
pos
–
QPoint
int
返回选项卡索引,覆盖
position
或 -1 若没有选项卡覆盖
position
;
PySide2.QtWidgets.QTabBar.
tabBarClicked
(
index
)
¶
index
–
int
PySide2.QtWidgets.QTabBar.
tabBarDoubleClicked
(
index
)
¶
index
–
int
PySide2.QtWidgets.QTabBar.
tabButton
(
index
,
position
)
¶
index
–
int
position
–
ButtonPosition
返回 Widget 设置选项卡
index
and
position
or
None
若尚未设置一个。
另请参阅
PySide2.QtWidgets.QTabBar.
tabCloseRequested
(
index
)
¶
index
–
int
PySide2.QtWidgets.QTabBar.
tabData
(
index
)
¶
index
–
int
object
返回选项卡的数据,在位置
index
,或 null 变体若
index
超出范围。
另请参阅
PySide2.QtWidgets.QTabBar.
tabIcon
(
index
)
¶
index
–
int
QIcon
返回选项卡的图标,在位置
index
,或 null 图标若
index
超出范围。
另请参阅
PySide2.QtWidgets.QTabBar.
tabInserted
(
index
)
¶
index
–
int
调用此虚拟处理程序,在添加或插入新选项卡后于位置
index
.
另请参阅
PySide2.QtWidgets.QTabBar.
tabMoved
(
from
,
to
)
¶
from
–
int
to
–
int
PySide2.QtWidgets.QTabBar.
tabRect
(
index
)
¶
index
–
int
QRect
返回选项卡的视觉矩形,在位置
index
,或 null 矩形若
index
被隐藏或超出范围。
PySide2.QtWidgets.QTabBar.
tabRemoved
(
index
)
¶
index
–
int
此虚拟处理程序被调用,在选项卡被移除后从位置
index
.
另请参阅
PySide2.QtWidgets.QTabBar.
tabSizeHint
(
index
)
¶
index
–
int
QSize
返回选项卡大小提示,在位置
index
.
PySide2.QtWidgets.QTabBar.
tabText
(
index
)
¶
index
–
int
unicode
返回选项卡的文本,在位置
index
,或空字符串若
index
超出范围。
另请参阅
PySide2.QtWidgets.QTabBar.
tabTextColor
(
index
)
¶
index
–
int
QColor
返回选项卡的文本颜色,采用给定
index
,或无效颜色若
index
超出范围。
另请参阅
PySide2.QtWidgets.QTabBar.
tabToolTip
(
index
)
¶
index
–
int
unicode
返回选项卡的工具提示,在位置
index
,或空字符串若
index
超出范围。
另请参阅
PySide2.QtWidgets.QTabBar.
tabWhatsThis
(
index
)
¶
index
–
int
unicode
Returns the What’s This help text of the tab at position
index
,或空字符串若
index
超出范围。
另请参阅
PySide2.QtWidgets.QTabBar.
tabsClosable
(
)
¶
bool
另请参阅
PySide2.QtWidgets.QTabBar.
usesScrollButtons
(
)
¶
bool