• PySide 模块
  • PySide.QtGui
  • 内容表

    上一话题

    QStatusBar

    下一话题

    QStackedWidget

    QTabBar

    概要

    函数

    虚函数

    信号

    详细描述

    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.

    ../../_images/plastique-tabbar.png A tab bar shown in the Plastique widget style.
    ../../_images/plastique-tabbar-truncated.png A truncated tab bar shown in the Plastique widget style.
    class PySide.QtGui. QTabBar ( [ parent=None ] )
    参数: parent PySide.QtGui.QWidget

    创建新的选项卡栏,采用给定 parent .

    PySide.QtGui.QTabBar. SelectionBehavior

    此枚举类型列表行为在 PySide.QtGui.QTabBar 当选项卡被移除且被移除选项卡也是当前选项卡时。

    常量 描述
    QTabBar.SelectLeftTab 选择被移除选项卡左侧的选项卡。
    QTabBar.SelectRightTab 选择被移除选项卡右侧的选项卡。
    QTabBar.SelectPreviousTab 选择先前选中的选项卡。
    PySide.QtGui.QTabBar. ButtonPosition

    此枚举类型列表 Widget 在选项卡上的位置。

    常量 描述
    QTabBar.LeftSide 选项卡的左侧。
    QTabBar.RightSide 选项卡的右侧。
    PySide.QtGui.QTabBar. 形状

    此枚举类型列出了受支持的内置形状,由 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.
    PySide.QtGui.QTabBar. addTab ( text )
    参数: text – unicode
    返回类型: PySide.QtCore.int

    添加新选项卡采用文本 text 。返回新选项卡的索引。

    PySide.QtGui.QTabBar. addTab ( icon , text )
    参数:
    返回类型:

    PySide.QtCore.int

    这是重载函数。

    添加新选项卡采用图标 icon 和文本 text 。返回新选项卡的索引。

    PySide.QtGui.QTabBar. count ( )
    返回类型: PySide.QtCore.int

    This property holds the number of tabs in the tab bar.

    PySide.QtGui.QTabBar. currentChanged ( index )
    参数: index PySide.QtCore.int
    PySide.QtGui.QTabBar. currentIndex ( )
    返回类型: PySide.QtCore.int

    This property holds the index of the tab bar's visible tab.

    当前索引为 -1,若没有当前选项卡。

    PySide.QtGui.QTabBar. documentMode ( )
    返回类型: 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.QtGui.QTabBar. drawBase ( )
    返回类型: 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.

    PySide.QtGui.QTabBar. elideMode ( )
    返回类型: PySide.QtCore.Qt.TextElideMode

    This property holds how to elide text in the tab bar.

    此特性控制如何省略项,当没有足够空间展示它们 (对于给定选项卡栏尺寸) 时。

    默认情况下,值从属样式。

    PySide.QtGui.QTabBar. expanding ( )
    返回类型: PySide.QtCore.bool

    This property holds When expanding is true PySide.QtGui.QTabBar will expand the tabs to use the empty space..

    默认情况下,值为 true。

    PySide.QtGui.QTabBar. iconSize ( )
    返回类型: 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.

    PySide.QtGui.QTabBar. initStyleOption ( option , tabIndex )
    参数:

    初始化 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.QtGui.QTabBar. insertTab ( index , icon , text )
    参数:
    返回类型:

    PySide.QtCore.int

    这是重载函数。

    插入新选项卡采用图标 icon 和文本 text 在位置 index 。若 index 超出范围,追加新选项卡。返回新选项卡的索引。

    PySide.QtGui.QTabBar 为空在调用此函数之前,插入选项卡变为当前选项卡。

    在 <= 当前索引的索引处插入新选项卡将递增当前索引,但保持当前选项卡。

    PySide.QtGui.QTabBar. insertTab ( index , text )
    参数:
    • index PySide.QtCore.int
    • text – unicode
    返回类型:

    PySide.QtCore.int

    插入新选项卡采用文本 text 在位置 index 。若 index 超出范围,追加新选项卡。返回新选项卡的索引。

    PySide.QtGui.QTabBar. isMovable ( )
    返回类型: 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;

    PySide.QtGui.QTabBar. isTabEnabled ( index )
    参数: index PySide.QtCore.int
    返回类型: PySide.QtCore.bool

    返回 true 若选项卡在位置 index is enabled; otherwise returns false.

    PySide.QtGui.QTabBar. moveTab ( from , to )
    参数:
    • from PySide.QtCore.int
    • to PySide.QtCore.int

    移动索引位置项 from 到索引位置 to .

    PySide.QtGui.QTabBar. removeTab ( index )
    参数: index PySide.QtCore.int

    移除选项卡,在位置 index .

    另请参阅

    QTabBar.SelectionBehavior

    PySide.QtGui.QTabBar. selectionBehaviorOnRemove ( )
    返回类型: 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 .

    PySide.QtGui.QTabBar. setCurrentIndex ( index )
    参数: index PySide.QtCore.int

    This property holds the index of the tab bar's visible tab.

    当前索引为 -1,若没有当前选项卡。

    PySide.QtGui.QTabBar. setDocumentMode ( set )
    参数: 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.

    PySide.QtGui.QTabBar. setDrawBase ( drawTheBase )
    参数: 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.

    PySide.QtGui.QTabBar. setElideMode ( arg__1 )
    参数: arg__1 PySide.QtCore.Qt.TextElideMode

    This property holds how to elide text in the tab bar.

    此特性控制如何省略项,当没有足够空间展示它们 (对于给定选项卡栏尺寸) 时。

    默认情况下,值从属样式。

    PySide.QtGui.QTabBar. setExpanding ( enabled )
    参数: enabled PySide.QtCore.bool

    This property holds When expanding is true PySide.QtGui.QTabBar will expand the tabs to use the empty space..

    默认情况下,值为 true。

    PySide.QtGui.QTabBar. setIconSize ( size )
    参数: 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.

    PySide.QtGui.QTabBar. setMovable ( movable )
    参数: 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;

    PySide.QtGui.QTabBar. setSelectionBehaviorOnRemove ( behavior )
    参数: 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 .

    PySide.QtGui.QTabBar. setShape ( shape )
    参数: shape PySide.QtGui.QTabBar.Shape

    This property holds the shape of the tabs in the tab bar.

    此特性的可能值,由形状枚举描述。

    PySide.QtGui.QTabBar. setTabButton ( index , position , widget )
    参数:

    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).

    PySide.QtGui.QTabBar. setTabData ( index , data )
    参数:
    • index PySide.QtCore.int
    • data – object

    设置选项卡的数据,在位置 index to data .

    PySide.QtGui.QTabBar. setTabEnabled ( index , arg__2 )
    参数:
    • index PySide.QtCore.int
    • arg__2 PySide.QtCore.bool

    enabled 为 true 则选项卡在位置 index 被启用;否则项在位置 index 是禁用的。

    PySide.QtGui.QTabBar. setTabIcon ( index , icon )
    参数:

    设置选项卡的图标,在位置 index to icon .

    PySide.QtGui.QTabBar. setTabText ( index , text )
    参数:
    • index PySide.QtCore.int
    • text – unicode

    设置选项卡的文本,在位置 index to text .

    PySide.QtGui.QTabBar. setTabTextColor ( index , color )
    参数:

    设置选项卡文本颜色采用给定 index 到指定 color .

    如果指定的是无效颜色,选项卡将使用 PySide.QtGui.QTabBar 前景角色代替。

    PySide.QtGui.QTabBar. setTabToolTip ( index , tip )
    参数:
    • index PySide.QtCore.int
    • tip – unicode

    设置选项卡的工具提示,在位置 index to tip .

    PySide.QtGui.QTabBar. setTabWhatsThis ( index , text )
    参数:
    • index PySide.QtCore.int
    • text – unicode

    设置选项卡的 What's This 帮助文本,在位置 index to text .

    PySide.QtGui.QTabBar. setTabsClosable ( closable )
    参数: 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。

    PySide.QtGui.QTabBar. setUsesScrollButtons ( useButtons )
    参数: 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 ( )
    返回类型: PySide.QtGui.QTabBar.Shape

    This property holds the shape of the tabs in the tab bar.

    此特性的可能值,由形状枚举描述。

    PySide.QtGui.QTabBar. tabAt ( pos )
    参数: pos PySide.QtCore.QPoint
    返回类型: PySide.QtCore.int

    返回选项卡索引,覆盖 position 或 -1 若没有选项卡覆盖 position ;

    PySide.QtGui.QTabBar. tabButton ( index , position )
    参数:
    返回类型:

    PySide.QtGui.QWidget

    返回 Widget 设置选项卡 index and position or 0 if one is not set.

    PySide.QtGui.QTabBar. tabCloseRequested ( index )
    参数: index PySide.QtCore.int
    PySide.QtGui.QTabBar. tabData ( index )
    参数: index PySide.QtCore.int
    返回类型: object

    返回选项卡的数据,在位置 index ,或 null 变体若 index 超出范围。

    PySide.QtGui.QTabBar. tabIcon ( index )
    参数: index PySide.QtCore.int
    返回类型: PySide.QtGui.QIcon

    返回选项卡的图标,在位置 index ,或 null 图标若 index 超出范围。

    PySide.QtGui.QTabBar. tabInserted ( index )
    参数: index PySide.QtCore.int

    调用此虚拟处理程序,在添加或插入新选项卡后于位置 index .

    PySide.QtGui.QTabBar. tabLayoutChange ( )

    此虚拟处理程序被调用,每当选项卡布局改变时。

    PySide.QtGui.QTabBar. tabMoved ( from , to )
    参数:
    • from PySide.QtCore.int
    • to PySide.QtCore.int
    PySide.QtGui.QTabBar. tabRect ( index )
    参数: index PySide.QtCore.int
    返回类型: PySide.QtCore.QRect

    返回选项卡的视觉矩形,在位置 index ,或 null 矩形若 index 超出范围。

    PySide.QtGui.QTabBar. tabRemoved ( index )
    参数: index PySide.QtCore.int

    此虚拟处理程序被调用,在选项卡被移除后从位置 index .

    PySide.QtGui.QTabBar. tabSizeHint ( index )
    参数: index PySide.QtCore.int
    返回类型: PySide.QtCore.QSize

    返回选项卡大小提示,在位置 index .

    PySide.QtGui.QTabBar. tabText ( index )
    参数: index PySide.QtCore.int
    返回类型: unicode

    返回选项卡的文本,在位置 index ,或空字符串若 index 超出范围。

    PySide.QtGui.QTabBar. tabTextColor ( index )
    参数: index PySide.QtCore.int
    返回类型: PySide.QtGui.QColor

    返回选项卡的文本颜色,采用给定 index ,或无效颜色若 index 超出范围。

    PySide.QtGui.QTabBar. tabToolTip ( index )
    参数: index PySide.QtCore.int
    返回类型: unicode

    返回选项卡的工具提示,在位置 index ,或空字符串若 index 超出范围。

    PySide.QtGui.QTabBar. tabWhatsThis ( index )
    参数: index PySide.QtCore.int
    返回类型: unicode

    返回选项卡的 What's This 帮助文本,在位置 index ,或空字符串若 index 超出范围。

    PySide.QtGui.QTabBar. tabsClosable ( )
    返回类型: 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.QtGui.QTabBar. usesScrollButtons ( )
    返回类型: 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