内容表

上一话题

QTimeEdit

下一话题

QToolBox

QToolBar

QToolBar class provides a movable panel that contains a set of controls. 更多

Inheritance diagram of PySide2.QtWidgets.QToolBar

概要

函数

信号

详细描述

工具栏按钮被添加通过添加 actions ,使用 addAction() or insertAction() . Groups of buttons can be separated using addSeparator() or insertSeparator() . If a toolbar button is not appropriate, a widget can be inserted instead using addWidget() or insertWidget() . Examples of suitable widgets are QSpinBox , QDoubleSpinBox ,和 QComboBox . When a toolbar button is pressed, it emits the actionTriggered() 信号。

A toolbar can be fixed in place in a particular area (e.g., at the top of the window), or it can be movable between toolbar areas; see setMovable() , isMovable() , allowedAreas() and isAreaAllowed() .

When a toolbar is resized in such a way that it is too small to show all the items it contains, an extension button will appear as the last item in the toolbar. Pressing the extension button will pop up a menu containing the items that do not currently fit in the toolbar.

QToolBar is not a child of a QMainWindow , it loses the ability to populate the extension pop up with widgets added to the toolbar using addWidget() . Please use widget actions created by inheriting QWidgetAction and implementing createWidget() 代替。

class QToolBar ( [ parent=None ] )

QToolBar(title[, parent=None])

param parent

QWidget

param title

unicode

构造 QToolBar 采用给定 parent .

构造 QToolBar 采用给定 parent .

The given window title identifies the toolbar and is shown in the context menu provided by QMainWindow .

另请参阅

setWindowTitle()

PySide2.QtWidgets.QToolBar. actionAt ( p )
参数

p QPoint

返回类型

QAction

Returns the action at point p . This function returns zero if no action was found.

另请参阅

childAt()

PySide2.QtWidgets.QToolBar. actionAt ( x , y )
参数
  • x int

  • y int

返回类型

QAction

这是重载函数。

Returns the action at the point x , y . This function returns zero if no action was found.

PySide2.QtWidgets.QToolBar. actionGeometry ( action )
参数

action QAction

返回类型

QRect

Returns the geometry of the toolbar item associated with the given action , or an invalid QRect if no matching item is found.

PySide2.QtWidgets.QToolBar. actionTriggered ( action )
参数

action QAction

PySide2.QtWidgets.QToolBar. addAction ( icon , text )
参数
  • icon QIcon

  • text – unicode

返回类型

QAction

PySide2.QtWidgets.QToolBar. addAction ( icon , text , receiver )
参数
  • icon QIcon

  • text – unicode

  • receiver QObject

返回类型

QAction

PySide2.QtWidgets.QToolBar. addAction ( text )
参数

text – unicode

返回类型

QAction

创建新的动作采用给定 text . This action is added to the end of the toolbar.

PySide2.QtWidgets.QToolBar. addAction ( text , receiver )
参数
  • text – unicode

  • receiver QObject

返回类型

QAction

PySide2.QtWidgets.QToolBar. addSeparator ( )
返回类型

QAction

Adds a separator to the end of the toolbar.

另请参阅

insertSeparator()

PySide2.QtWidgets.QToolBar. addWidget ( widget )
参数

widget QWidget

返回类型

QAction

添加给定 widget to the toolbar as the toolbar’s last item.

The toolbar takes ownership of widget .

若添加 QToolButton with this method, the toolbar’s ToolButtonStyle will not be respected.

注意

应使用 setVisible() to change the visibility of the widget. Using setVisible() , show() and hide() does not work.

另请参阅

insertWidget()

PySide2.QtWidgets.QToolBar. allowedAreas ( )
返回类型

ToolBarAreas

另请参阅

setAllowedAreas()

PySide2.QtWidgets.QToolBar. allowedAreasChanged ( allowedAreas )
参数

allowedAreas ToolBarAreas

PySide2.QtWidgets.QToolBar. clear ( )

Removes all actions from the toolbar.

另请参阅

removeAction()

PySide2.QtWidgets.QToolBar. iconSize ( )
返回类型

QSize

另请参阅

setIconSize()

PySide2.QtWidgets.QToolBar. iconSizeChanged ( iconSize )
参数

iconSize QSize

PySide2.QtWidgets.QToolBar. initStyleOption ( option )
参数

option QStyleOptionToolBar

PySide2.QtWidgets.QToolBar. insertSeparator ( before )
参数

before QAction

返回类型

QAction

Inserts a separator into the toolbar in front of the toolbar item associated with the before action.

另请参阅

addSeparator()

PySide2.QtWidgets.QToolBar. insertWidget ( before , widget )
参数
返回类型

QAction

Inserts the given widget in front of the toolbar item associated with the before action.

Note: You should use setVisible() to change the visibility of the widget. Using setVisible() , show() and hide() does not work.

另请参阅

addWidget()

PySide2.QtWidgets.QToolBar. isAreaAllowed ( area )
参数

area ToolBarArea

返回类型

bool

返回 true if this toolbar is dockable in the given area ;否则返回 false .

PySide2.QtWidgets.QToolBar. isFloatable ( )
返回类型

bool

PySide2.QtWidgets.QToolBar. isFloating ( )
返回类型

bool

PySide2.QtWidgets.QToolBar. isMovable ( )
返回类型

bool

PySide2.QtWidgets.QToolBar. movableChanged ( movable )
参数

movable bool

PySide2.QtWidgets.QToolBar. orientation ( )
返回类型

取向

另请参阅

setOrientation()

PySide2.QtWidgets.QToolBar. orientationChanged ( orientation )
参数

orientation 取向

PySide2.QtWidgets.QToolBar. setAllowedAreas ( areas )
参数

areas ToolBarAreas

另请参阅

allowedAreas()

PySide2.QtWidgets.QToolBar. setFloatable ( floatable )
参数

floatable bool

另请参阅

isFloatable()

PySide2.QtWidgets.QToolBar. setIconSize ( iconSize )
参数

iconSize QSize

另请参阅

iconSize()

PySide2.QtWidgets.QToolBar. setMovable ( movable )
参数

movable bool

另请参阅

isMovable()

PySide2.QtWidgets.QToolBar. setOrientation ( orientation )
参数

orientation 取向

另请参阅

orientation()

PySide2.QtWidgets.QToolBar. setToolButtonStyle ( toolButtonStyle )
参数

toolButtonStyle ToolButtonStyle

另请参阅

toolButtonStyle()

PySide2.QtWidgets.QToolBar. toggleViewAction ( )
返回类型

QAction

Returns a checkable action that can be used to show or hide this toolbar.

The action’s text is set to the toolbar’s window title.

另请参阅

text windowTitle

PySide2.QtWidgets.QToolBar. toolButtonStyle ( )
返回类型

ToolButtonStyle

PySide2.QtWidgets.QToolBar. toolButtonStyleChanged ( toolButtonStyle )
参数

toolButtonStyle ToolButtonStyle

PySide2.QtWidgets.QToolBar. topLevelChanged ( topLevel )
参数

topLevel bool

PySide2.QtWidgets.QToolBar. visibilityChanged ( visible )
参数

visible bool

PySide2.QtWidgets.QToolBar. widgetForAction ( action )
参数

action QAction

返回类型

QWidget

Returns the widget associated with the specified action .

另请参阅

addWidget()