PySide.QtGui.QTabBar class provides a tab bar, e.g. for use in tabbed dialogs.
PySide.QtGui.QTabBar is straightforward to use; it draws the tabs using one of the predefined shapes ,并发射信号,当选项卡被选中时。它可以被子类化以订制外观和感觉。Qt 还提供现成 PySide.QtGui.QTabWidget .
每个选项卡有 PySide.QtGui.QTabBar.tabText() , an optional PySide.QtGui.QTabBar.tabIcon() , an optional PySide.QtGui.QTabBar.tabToolTip() , optional PySide.QtGui.QTabBar.tabWhatsThis() 和可选 PySide.QtGui.QTabBar.tabData() . The tabs's attributes can be changed with PySide.QtGui.QTabBar.setTabText() , PySide.QtGui.QTabBar.setTabIcon() , PySide.QtGui.QTabBar.setTabToolTip() , setTabWhatsThis and PySide.QtGui.QTabBar.setTabData() . Each tabs can be enabled or disabled individually with PySide.QtGui.QTabBar.setTabEnabled() .
每个选项卡可以按截然不同颜色显示文本。可以找到当前选项卡的文本颜色采用 PySide.QtGui.QTabBar.tabTextColor() function. Set the text color for a particular tab with PySide.QtGui.QTabBar.setTabTextColor() .
添加选项卡使用 PySide.QtGui.QTabBar.addTab() , or inserted at particular positions using PySide.QtGui.QTabBar.insertTab() . The total number of tabs is given by PySide.QtGui.QTabBar.count() . Tabs can be removed from the tab bar with PySide.QtGui.QTabBar.removeTab() . Combining PySide.QtGui.QTabBar.removeTab() and PySide.QtGui.QTabBar.insertTab() allows you to move tabs to different positions.
PySide.QtGui.QTabBar.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 ,而 RoundedSouth is used mostly when the pages are different (e.g. a multi-page tool palette). The default in PySide.QtGui.QTabBar is RoundedNorth .
The most important part of PySide.QtGui.QTabBar ‘s API is the PySide.QtGui.QTabBar.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, PySide.QtGui.QTabBar.setCurrentIndex() , which can be used to select a tab programmatically. The function PySide.QtGui.QTabBar.currentIndex() returns the index of the current tab, PySide.QtGui.QTabBar.count() holds the number of tabs.
PySide.QtGui.QTabBar creates automatic mnemonic keys in the manner of PySide.QtGui.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:
对于子类,可能还需要 PySide.QtGui.QTabBar.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. |
| 参数: | parent – PySide.QtGui.QWidget |
|---|
创建新的选项卡栏,采用给定 parent .
此枚举类型列表行为在 PySide.QtGui.QTabBar 当选项卡被移除且被移除选项卡也是当前选项卡时。
| 常量 | 描述 |
|---|---|
| QTabBar.SelectLeftTab | 选择被移除选项卡左侧的选项卡。 |
| QTabBar.SelectRightTab | 选择被移除选项卡右侧的选项卡。 |
| QTabBar.SelectPreviousTab | 选择先前选中的选项卡。 |
此枚举类型列表 Widget 在选项卡上的位置。
| 常量 | 描述 |
|---|---|
| QTabBar.LeftSide | 选项卡的左侧。 |
| QTabBar.RightSide | 选项卡的右侧。 |
此枚举类型列出了受支持的内置形状,由 PySide.QtGui.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. |
| 参数: | text – unicode |
|---|---|
| 返回类型: | PySide.QtCore.int |
添加新选项卡采用文本 text 。返回新选项卡的索引。
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.int |
这是重载函数。
添加新选项卡采用图标 icon 和文本 text 。返回新选项卡的索引。
| 返回类型: | PySide.QtCore.int |
|---|
This property holds the number of tabs in the tab bar.
| 参数: | index – PySide.QtCore.int |
|---|
| 返回类型: | PySide.QtCore.int |
|---|
This property holds the index of the tab bar's visible tab.
当前索引为 -1,若没有当前选项卡。
| 返回类型: | PySide.QtCore.bool |
|---|
This property holds Whether or not the tab bar is rendered in a mode suitable for the main window..
This property is used as a hint for styles to draw the tabs in a different way then they would normally look in a tab widget. On Mac OS X this will look similar to the tabs in Safari or Leopard's Terminal.app.
| 返回类型: | PySide.QtCore.bool |
|---|
This property defines whether or not tab bar should draw its base..
若 true 则 PySide.QtGui.QTabBar draws a base in relation to the styles overlab. Otherwise only the tabs are drawn.
另请参阅
QStyle.pixelMetric() QStyle.PM_TabBarBaseOverlap PySide.QtGui.QStyleOptionTabBarBaseV2
| 返回类型: | PySide.QtCore.Qt.TextElideMode |
|---|
This property holds how to elide text in the tab bar.
此特性控制如何省略项,当没有足够空间展示它们 (对于给定选项卡栏尺寸) 时。
默认情况下,值从属样式。
另请参阅
QTabWidget.elideMode PySide.QtGui.QTabBar.usesScrollButtons() QStyle.SH_TabBar_ElideMode
| 返回类型: | PySide.QtCore.bool |
|---|
This property holds When expanding is true PySide.QtGui.QTabBar will expand the tabs to use the empty space..
默认情况下,值为 true。
| 返回类型: | PySide.QtCore.QSize |
|---|
This property holds The size for icons in the tab bar.
默认值从属样式。 iconSize is a maximum size; icons that are smaller are not scaled up.
另请参阅
| 参数: |
|
|---|
初始化 option 采用值从选项卡在 tabIndex 。此方法对子类是有用的,当需要 PySide.QtGui.QStyleOptionTab , PySide.QtGui.QStyleOptionTabV2 ,或 PySide.QtGui.QStyleOptionTabV3 but don't want to fill in all the information themselves. This function will check the version of the PySide.QtGui.QStyleOptionTab and fill in the additional values for a PySide.QtGui.QStyleOptionTabV2 and PySide.QtGui.QStyleOptionTabV3 .
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.int |
这是重载函数。
插入新选项卡采用图标 icon 和文本 text 在位置 index 。若 index 超出范围,追加新选项卡。返回新选项卡的索引。
若 PySide.QtGui.QTabBar 为空在调用此函数之前,插入选项卡变为当前选项卡。
在 <= 当前索引的索引处插入新选项卡将递增当前索引,但保持当前选项卡。
| 参数: |
|
|---|---|
| 返回类型: |
PySide.QtCore.int |
插入新选项卡采用文本 text 在位置 index 。若 index 超出范围,追加新选项卡。返回新选项卡的索引。
| 返回类型: | PySide.QtCore.bool |
|---|
This property holds This property holds whether the user can move the tabs within the tabbar area..
By default, this property is false;
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.bool |
返回 true 若选项卡在位置 index is enabled; otherwise returns false.
| 参数: |
|
|---|
移动索引位置项 from 到索引位置 to .
| 参数: | index – PySide.QtCore.int |
|---|
移除选项卡,在位置 index .
另请参阅
QTabBar.SelectionBehavior
| 返回类型: | PySide.QtGui.QTabBar.SelectionBehavior |
|---|
This property holds What tab should be set as current when removeTab is called if the removed tab is also the current tab..
默认情况下,值为 SelectRightTab .
| 参数: | index – PySide.QtCore.int |
|---|
This property holds the index of the tab bar's visible tab.
当前索引为 -1,若没有当前选项卡。
| 参数: | set – PySide.QtCore.bool |
|---|
This property holds Whether or not the tab bar is rendered in a mode suitable for the main window..
This property is used as a hint for styles to draw the tabs in a different way then they would normally look in a tab widget. On Mac OS X this will look similar to the tabs in Safari or Leopard's Terminal.app.
| 参数: | drawTheBase – PySide.QtCore.bool |
|---|
This property defines whether or not tab bar should draw its base..
若 true 则 PySide.QtGui.QTabBar draws a base in relation to the styles overlab. Otherwise only the tabs are drawn.
另请参阅
QStyle.pixelMetric() QStyle.PM_TabBarBaseOverlap PySide.QtGui.QStyleOptionTabBarBaseV2
| 参数: | arg__1 – PySide.QtCore.Qt.TextElideMode |
|---|
This property holds how to elide text in the tab bar.
此特性控制如何省略项,当没有足够空间展示它们 (对于给定选项卡栏尺寸) 时。
默认情况下,值从属样式。
另请参阅
QTabWidget.elideMode PySide.QtGui.QTabBar.usesScrollButtons() QStyle.SH_TabBar_ElideMode
| 参数: | enabled – PySide.QtCore.bool |
|---|
This property holds When expanding is true PySide.QtGui.QTabBar will expand the tabs to use the empty space..
默认情况下,值为 true。
| 参数: | size – PySide.QtCore.QSize |
|---|
This property holds The size for icons in the tab bar.
默认值从属样式。 iconSize is a maximum size; icons that are smaller are not scaled up.
另请参阅
| 参数: | movable – PySide.QtCore.bool |
|---|
This property holds This property holds whether the user can move the tabs within the tabbar area..
By default, this property is false;
| 参数: | behavior – PySide.QtGui.QTabBar.SelectionBehavior |
|---|
This property holds What tab should be set as current when removeTab is called if the removed tab is also the current tab..
默认情况下,值为 SelectRightTab .
| 参数: | shape – PySide.QtGui.QTabBar.Shape |
|---|
This property holds the shape of the tabs in the tab bar.
此特性的可能值,由形状枚举描述。
| 参数: |
|
|---|
集 widget 在选项卡 index 。Widget 被放置在左侧或右侧从属 position .
任何先前设置 Widget 在 position 被隐藏。
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).
| 参数: |
|
|---|
设置选项卡的数据,在位置 index to data .
| 参数: |
|
|---|
若 enabled 为 true 则选项卡在位置 index 被启用;否则项在位置 index 是禁用的。
| 参数: |
|
|---|
设置选项卡的图标,在位置 index to icon .
| 参数: |
|
|---|
设置选项卡的文本,在位置 index to text .
| 参数: |
|
|---|
设置选项卡文本颜色采用给定 index 到指定 color .
如果指定的是无效颜色,选项卡将使用 PySide.QtGui.QTabBar 前景角色代替。
| 参数: |
|
|---|
设置选项卡的工具提示,在位置 index to tip .
| 参数: |
|
|---|
设置选项卡的 What's This 帮助文本,在位置 index to text .
| 参数: | closable – PySide.QtCore.bool |
|---|
This property holds Whether or not a tab bar should place close buttons on each tab.
当 PySide.QtGui.QTabBar.tabsClosable() is set to true a close button will appear on the tab on either the left or right hand side depending upon the style. When the button is clicked the tab the signal tabCloseRequested will be emitted.
默认情况下,值为 false。
| 参数: | useButtons – PySide.QtCore.bool |
|---|
This property holds Whether or not a tab bar should use buttons to scroll tabs when it has many tabs..
当选项卡栏选项卡太多时 (对于其大小),选项卡栏可以选择展开其大小,或添加按钮以允许卷动选项卡。
默认情况下,值从属样式。
另请参阅
PySide.QtGui.QTabBar.elideMode() QTabWidget.usesScrollButtons QStyle.SH_TabBar_PreferNoArrows
| 返回类型: | PySide.QtGui.QTabBar.Shape |
|---|
This property holds the shape of the tabs in the tab bar.
此特性的可能值,由形状枚举描述。
| 参数: | pos – PySide.QtCore.QPoint |
|---|---|
| 返回类型: | PySide.QtCore.int |
返回选项卡索引,覆盖 position 或 -1 若没有选项卡覆盖 position ;
| 参数: |
|
|---|---|
| 返回类型: |
返回 Widget 设置选项卡 index and position or 0 if one is not set.
| 参数: | index – PySide.QtCore.int |
|---|
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | object |
返回选项卡的数据,在位置 index ,或 null 变体若 index 超出范围。
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtGui.QIcon |
返回选项卡的图标,在位置 index ,或 null 图标若 index 超出范围。
| 参数: | index – PySide.QtCore.int |
|---|
调用此虚拟处理程序,在添加或插入新选项卡后于位置 index .
此虚拟处理程序被调用,每当选项卡布局改变时。
| 参数: |
|
|---|
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.QRect |
返回选项卡的视觉矩形,在位置 index ,或 null 矩形若 index 超出范围。
| 参数: | index – PySide.QtCore.int |
|---|
此虚拟处理程序被调用,在选项卡被移除后从位置 index .
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtCore.QSize |
返回选项卡大小提示,在位置 index .
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | unicode |
返回选项卡的文本,在位置 index ,或空字符串若 index 超出范围。
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | PySide.QtGui.QColor |
返回选项卡的文本颜色,采用给定 index ,或无效颜色若 index 超出范围。
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | unicode |
返回选项卡的工具提示,在位置 index ,或空字符串若 index 超出范围。
| 参数: | index – PySide.QtCore.int |
|---|---|
| 返回类型: | unicode |
返回选项卡的 What's This 帮助文本,在位置 index ,或空字符串若 index 超出范围。
| 返回类型: | PySide.QtCore.bool |
|---|
This property holds Whether or not a tab bar should place close buttons on each tab.
当 PySide.QtGui.QTabBar.tabsClosable() is set to true a close button will appear on the tab on either the left or right hand side depending upon the style. When the button is clicked the tab the signal tabCloseRequested will be emitted.
默认情况下,值为 false。
| 返回类型: | PySide.QtCore.bool |
|---|
This property holds Whether or not a tab bar should use buttons to scroll tabs when it has many tabs..
当选项卡栏选项卡太多时 (对于其大小),选项卡栏可以选择展开其大小,或添加按钮以允许卷动选项卡。
默认情况下,值从属样式。
另请参阅
PySide.QtGui.QTabBar.elideMode() QTabWidget.usesScrollButtons QStyle.SH_TabBar_PreferNoArrows