QTabWidgetclass provides a stack of tabbed widgets. 更多 …
def
addTab
(widget, arg__2)
def
addTab
(widget, icon, label)
def
clear
()
def
cornerWidget
([corner=Qt.TopRightCorner])
def
count
()
def
currentIndex
()
def
currentWidget
()
def
documentMode
()
def
elideMode
()
def
iconSize
()
def
indexOf
(widget)
def
initStyleOption
(option)
def
insertTab
(index, widget, arg__3)
def
insertTab
(index, widget, icon, label)
def
isMovable
()
def
isTabEnabled
(index)
def
isTabVisible
(index)
def
removeTab
(index)
def
setCornerWidget
(w[, corner=Qt.TopRightCorner])
def
setDocumentMode
(set)
def
setElideMode
(mode)
def
setIconSize
(size)
def
setMovable
(movable)
def
setTabBar
(arg__1)
def
setTabBarAutoHide
(enabled)
def
setTabEnabled
(index, enabled)
def
setTabIcon
(index, icon)
def
setTabPosition
(position)
def
setTabShape
(s)
def
setTabText
(index, text)
def
setTabToolTip
(index, tip)
def
setTabVisible
(index, visible)
def
setTabWhatsThis
(index, text)
def
setTabsClosable
(closeable)
def
setUsesScrollButtons
(useButtons)
def
tabBar
()
def
tabBarAutoHide
()
def
tabIcon
(index)
def
tabPosition
()
def
tabShape
()
def
tabText
(index)
def
tabToolTip
(index)
def
tabWhatsThis
(index)
def
tabsClosable
()
def
usesScrollButtons
()
def
widget
(index)
def
tabInserted
(index)
def
tabRemoved
(index)
def
setCurrentIndex
(index)
def
setCurrentWidget
(widget)
def
currentChanged
(index)
def
tabBarClicked
(index)
def
tabBarDoubleClicked
(index)
def
tabCloseRequested
(index)
![]()
选项卡小部件提供选项卡栏 (见
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 (seeTabPosition). 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
QTabWidgetis to do the following:
创建
QTabWidget.创建
QWidget对于每选项卡对话框页面,但不要为它们指定父级小部件。将子级 Widget 插入页面小部件,使用布局正常安放它们。
调用
addTab()orinsertTab()to put the page widgets into the tab widget, giving each tab a suitable label with an optional keyboard shortcut.选项卡位置的定义通过
tabPosition,它们的形状通过tabShape.信号
currentChanged()is emitted when the user selects a page.当前页面索引可用作
currentIndex(), the current page widget withcurrentWidget(). You can retrieve a pointer to a page widget with a given index usingwidget(), and can find the index position of a widget withindexOf()。使用setCurrentWidget()orsetCurrentIndex()to show a particular page.You can change a tab’s text and icon using
setTabText()orsetTabIcon(). A tab and its associated page can be removed withremoveTab().可以随时启用或禁用每选项卡 (见
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.选项卡小部件可以是拆分复杂对话框的很好方式。另一方式是使用
QStackedWidget提供在页面之间导航的一些手段,例如QToolBar或QListWidget.Most of the functionality in
QTabWidgetis provided by aQTabBar(在顶部,提供选项卡) 和QStackedWidget(大部分区域,组织各个页面)。
PySide2.QtWidgets.QTabWidget.
TabPosition
¶
此枚举类型定义在哪里
QTabWidget
绘制选项卡行:
|
常量 |
描述 |
|---|---|
|
QTabWidget.North |
选项卡绘制在页面上方。 |
|
QTabWidget.South |
选项卡绘制在页面下方。 |
|
QTabWidget.West |
选项卡绘制在页面左侧。 |
|
QTabWidget.East |
选项卡绘制在页面右侧。 |
PySide2.QtWidgets.QTabWidget.
TabShape
¶
此枚举类型定义选项卡的形状:
|
常量 |
描述 |
|---|---|
|
QTabWidget.Rounded |
选项卡采用圆角外观绘制。这是默认形状。 |
|
QTabWidget.Triangular |
选项卡采用三角形外观绘制。 |
PySide2.QtWidgets.QTabWidget.
addTab
(
widget
,
icon
,
label
)
¶
widget
–
QWidget
icon
–
QIcon
label – unicode
int
这是重载函数。
添加选项卡采用给定
page
,
icon
,和
label
到选项卡 Widget,并返回选项卡在选项卡栏中的索引。所有权为
page
被传递给
QTabWidget
.
This function is the same as
addTab()
, but with an additional
icon
.
PySide2.QtWidgets.QTabWidget.
addTab
(
widget
,
arg__2
)
¶
widget
–
QWidget
arg__2 – unicode
int
添加选项卡采用给定
page
and
label
到选项卡 Widget,并返回选项卡在选项卡栏中的索引。所有权为
page
被传递给
QTabWidget
.
If the tab’s
label
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 you call after
show()
, the layout system will try to adjust to the changes in its widgets hierarchy and may cause flicker. To prevent this, you can set the
updatesEnabled
特性为 false 在改变前;记得设置特性为 true 当改变完成后,使小部件再次接收描绘事件。
另请参阅
PySide2.QtWidgets.QTabWidget.
clear
(
)
¶
移除所有页面,但不删除它们。调用此函数相当于调用
removeTab()
until the tab widget is empty.
PySide2.QtWidgets.QTabWidget.
cornerWidget
(
[
corner=Qt.TopRightCorner
]
)
¶
corner
–
Corner
返回的 Widget 展示在
corner
对于选项卡小部件或
None
.
另请参阅
PySide2.QtWidgets.QTabWidget.
count
(
)
¶
int
PySide2.QtWidgets.QTabWidget.
currentChanged
(
index
)
¶
index
–
int
PySide2.QtWidgets.QTabWidget.
currentIndex
(
)
¶
int
另请参阅
PySide2.QtWidgets.QTabWidget.
currentWidget
(
)
¶
返回由选项卡对话框所显示的目前页面指针。选项卡对话框会尽力确保此值从不为 0 (但若足够努力,可以)。
PySide2.QtWidgets.QTabWidget.
documentMode
(
)
¶
bool
另请参阅
PySide2.QtWidgets.QTabWidget.
elideMode
(
)
¶
TextElideMode
另请参阅
PySide2.QtWidgets.QTabWidget.
iconSize
(
)
¶
QSize
另请参阅
PySide2.QtWidgets.QTabWidget.
indexOf
(
widget
)
¶
widget
–
QWidget
int
返回页面占据的索引位置由 Widget
w
,或 -1 若找不到 Widget。
PySide2.QtWidgets.QTabWidget.
initStyleOption
(
option
)
¶
option
–
QStyleOptionTabWidgetFrame
初始化
option
采用值来自此
QTabWidget
。此方法对子类是有用的,当需要
QStyleOptionTabWidgetFrame
, but don’t want to fill in all the information themselves.
PySide2.QtWidgets.QTabWidget.
insertTab
(
index
,
widget
,
icon
,
label
)
¶
index
–
int
widget
–
QWidget
icon
–
QIcon
label – unicode
int
这是重载函数。
插入选项卡采用给定
label
,
page
,和
icon
到选项卡小部件在指定
index
,并返回插入在选项卡栏中的选项卡索引。所有权在
page
被传递给
QTabWidget
.
This function is the same as
insertTab()
, but with an additional
icon
.
PySide2.QtWidgets.QTabWidget.
insertTab
(
index
,
widget
,
arg__3
)
¶
index
–
int
widget
–
QWidget
arg__3 – unicode
int
插入选项卡采用给定
label
and
page
到选项卡小部件在指定
index
,并返回插入在选项卡栏中的选项卡索引。所有权在
page
被传递给
QTabWidget
.
标签显示在选项卡中且外观可能有所不同,从属选项卡小部件配置。
If the tab’s
label
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.
若
index
超出范围,只需追加选项卡。否则,将其插入在指定位置。
若
QTabWidget
为空在调用此函数之前,新页面变为当前页面。在 <= 当前索引的索引处插入新选项卡将递增当前索引,但保持当前页面。
注意
If you call after
show()
, the layout system will try to adjust to the changes in its widgets hierarchy and may cause flicker. To prevent this, you can set the
updatesEnabled
特性为 false 在改变前;记得设置特性为 true 当改变完成后,使小部件再次接收描绘事件。
另请参阅
PySide2.QtWidgets.QTabWidget.
isMovable
(
)
¶
bool
PySide2.QtWidgets.QTabWidget.
isTabEnabled
(
index
)
¶
index
–
int
bool
返回
true
若页面在位置
index
被启用;否则返回
false
.
PySide2.QtWidgets.QTabWidget.
isTabVisible
(
index
)
¶
index
–
int
bool
返回 true 若页面在位置
index
可见;否则返回 false。
另请参阅
PySide2.QtWidgets.QTabWidget.
removeTab
(
index
)
¶
index
–
int
移除选项卡,在位置
index
从此 Widget 堆栈。页面 Widget 本身未被删除。
另请参阅
PySide2.QtWidgets.QTabWidget.
setCornerWidget
(
w
[
,
corner=Qt.TopRightCorner
]
)
¶
w
–
QWidget
corner
–
Corner
设置给定
widget
以展示在指定
corner
of the tab widget. The geometry of the widget is determined based on the widget’s
sizeHint()
和
style()
.
仅水平元素的
corner
会被使用。
传递
None
不展示角落 Widget。
任何先前设置的角落 Widget 均被隐藏。
选项卡小部件会删除此处设置的所有 Widget 当销毁它时,除非单独重设小部件父级先于设置一些其它角落小部件 (或
None
).
注意:角落小部件被设计为
North
and
South
选项卡位置;其它已知取向工作不正确。
PySide2.QtWidgets.QTabWidget.
setCurrentIndex
(
index
)
¶
index
–
int
另请参阅
PySide2.QtWidgets.QTabWidget.
setCurrentWidget
(
widget
)
¶
widget
–
QWidget
Makes
widget
当前小部件。
widget
使用的必须是此选项卡小部件的页面。
PySide2.QtWidgets.QTabWidget.
setDocumentMode
(
set
)
¶
set
–
bool
另请参阅
PySide2.QtWidgets.QTabWidget.
setElideMode
(
mode
)
¶
mode
–
TextElideMode
另请参阅
PySide2.QtWidgets.QTabWidget.
setIconSize
(
size
)
¶
size
–
QSize
另请参阅
PySide2.QtWidgets.QTabWidget.
setMovable
(
movable
)
¶
movable
–
bool
另请参阅
PySide2.QtWidgets.QTabWidget.
setTabBar
(
arg__1
)
¶
arg__1
–
QTabBar
Replaces the dialog’s
QTabBar
头采用选项卡栏
tb
。注意,这必须被调用
before
任何选项卡被添加,或行为不确定。
另请参阅
PySide2.QtWidgets.QTabWidget.
setTabBarAutoHide
(
enabled
)
¶
enabled
–
bool
另请参阅
PySide2.QtWidgets.QTabWidget.
setTabEnabled
(
index
,
enabled
)
¶
index
–
int
enabled
–
bool
若
enable
为 true,页面在位置
index
被启用;否则页面在位置
index
is disabled. The page’s tab is redrawn appropriately.
QTabWidget
使用
setEnabled()
internally, rather than keeping a separate flag.
注意,即使选项卡/页面被禁用也可能可见。若页面已经可见,
QTabWidget
不会隐藏它;若所有页面被禁用,
QTabWidget
将展示它们之一。
PySide2.QtWidgets.QTabWidget.
setTabIcon
(
index
,
icon
)
¶
index
–
int
icon
–
QIcon
设置
icon
为选项卡在位置
index
.
另请参阅
PySide2.QtWidgets.QTabWidget.
setTabPosition
(
position
)
¶
position
–
TabPosition
另请参阅
PySide2.QtWidgets.QTabWidget.
setTabText
(
index
,
text
)
¶
index
–
int
text – unicode
定义新
label
为页面,在位置
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 ‘&&’).
另请参阅
PySide2.QtWidgets.QTabWidget.
setTabToolTip
(
index
,
tip
)
¶
index
–
int
tip – unicode
设置选项卡工具提示为页面,在位置
index
to
tip
.
另请参阅
PySide2.QtWidgets.QTabWidget.
setTabVisible
(
index
,
visible
)
¶
index
–
int
visible
–
bool
若
visible
为 true,页面在位置
index
是可见的;否则页面在位置
index
is hidden. The page’s tab is redrawn appropriately.
另请参阅
PySide2.QtWidgets.QTabWidget.
setTabWhatsThis
(
index
,
text
)
¶
index
–
int
text – unicode
Sets the What’s This help text for the page at position
index
to
text
.
另请参阅
PySide2.QtWidgets.QTabWidget.
setTabsClosable
(
closeable
)
¶
closeable
–
bool
另请参阅
PySide2.QtWidgets.QTabWidget.
setUsesScrollButtons
(
useButtons
)
¶
useButtons
–
bool
另请参阅
PySide2.QtWidgets.QTabWidget.
tabBarAutoHide
(
)
¶
bool
另请参阅
PySide2.QtWidgets.QTabWidget.
tabBarClicked
(
index
)
¶
index
–
int
PySide2.QtWidgets.QTabWidget.
tabBarDoubleClicked
(
index
)
¶
index
–
int
PySide2.QtWidgets.QTabWidget.
tabCloseRequested
(
index
)
¶
index
–
int
PySide2.QtWidgets.QTabWidget.
tabIcon
(
index
)
¶
index
–
int
QIcon
返回页面选项卡图标,在位置
index
.
另请参阅
PySide2.QtWidgets.QTabWidget.
tabInserted
(
index
)
¶
index
–
int
调用此虚拟处理程序,在添加或插入新选项卡后于位置
index
.
另请参阅
PySide2.QtWidgets.QTabWidget.
tabPosition
(
)
¶
另请参阅
PySide2.QtWidgets.QTabWidget.
tabRemoved
(
index
)
¶
index
–
int
此虚拟处理程序被调用,在选项卡被移除后从位置
index
.
另请参阅
PySide2.QtWidgets.QTabWidget.
tabShape
(
)
¶
另请参阅
PySide2.QtWidgets.QTabWidget.
tabText
(
index
)
¶
index
–
int
unicode
返回页面选项卡标签文本,在位置
index
.
另请参阅
PySide2.QtWidgets.QTabWidget.
tabToolTip
(
index
)
¶
index
–
int
unicode
返回页面选项卡工具提示,在位置
index
或空字符串若未设置工具提示。
另请参阅
PySide2.QtWidgets.QTabWidget.
tabWhatsThis
(
index
)
¶
index
–
int
unicode
Returns the What’s This help text for the page at position
index
,或空字符串若未设置帮助文本。
另请参阅
PySide2.QtWidgets.QTabWidget.
tabsClosable
(
)
¶
bool
另请参阅
PySide2.QtWidgets.QTabWidget.
usesScrollButtons
(
)
¶
bool