QToolBar

The QToolBar class provides a movable panel that contains a set of controls. More

Inheritance diagram of PySide6.QtWidgets.QToolBar

Synopsis

Functions

Virtual functions

Slots

Signals

Detailed Description

Toolbar buttons are added by adding actions, using 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 , and QComboBox . When a toolbar button is pressed, it emits the actionTriggered() signal.

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.

When a 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() instead.

class PySide6.QtWidgets.QToolBar([parent=None])

PySide6.QtWidgets.QToolBar(title[, parent=None])

Parameters

Constructs a QToolBar with the given parent.

Constructs a QToolBar with the given parent.

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

See also

setWindowTitle()

PySide6.QtWidgets.QToolBar.actionAt(p)
Parameters

pPySide6.QtCore.QPoint

Return type

PySide6.QtGui.QAction

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

See also

childAt()

PySide6.QtWidgets.QToolBar.actionAt(x, y)
Parameters
  • x – int

  • y – int

Return type

PySide6.QtGui.QAction

This is an overloaded function.

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

PySide6.QtWidgets.QToolBar.actionGeometry(action)
Parameters

actionPySide6.QtGui.QAction

Return type

PySide6.QtCore.QRect

PySide6.QtWidgets.QToolBar.actionTriggered(action)
Parameters

actionPySide6.QtGui.QAction

PySide6.QtWidgets.QToolBar.addAction(icon, text)
Parameters
Return type

PySide6.QtGui.QAction

This is an overloaded function.

Creates a new action with the given icon and text. This action is added to the end of the toolbar.

PySide6.QtWidgets.QToolBar.addAction(icon, text, receiver)
Parameters
Return type

PySide6.QtGui.QAction

This is an overloaded function.

Creates a new action with the given icon and text. This action is added to the end of the toolbar. The action’s triggered() signal is connected to member in receiver.

PySide6.QtWidgets.QToolBar.addAction(text)
Parameters

text – str

Return type

PySide6.QtGui.QAction

Creates a new action with the given text. This action is added to the end of the toolbar.

PySide6.QtWidgets.QToolBar.addAction(text, receiver)
Parameters
Return type

PySide6.QtGui.QAction

This is an overloaded function.

Creates a new action with the given text. This action is added to the end of the toolbar. The action’s triggered() signal is connected to member in receiver.

PySide6.QtWidgets.QToolBar.addSeparator()
Return type

PySide6.QtGui.QAction

Adds a separator to the end of the toolbar.

PySide6.QtWidgets.QToolBar.addWidget(widget)
Parameters

widgetPySide6.QtWidgets.QWidget

Return type

PySide6.QtGui.QAction

Adds the given widget to the toolbar as the toolbar’s last item.

The toolbar takes ownership of widget.

If you add a QToolButton with this method, the toolbar’s ToolButtonStyle will not be respected.

Note

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

See also

insertWidget()

PySide6.QtWidgets.QToolBar.allowedAreas()
Return type

ToolBarAreas

This property holds areas where the toolbar may be placed.

The default is AllToolBarAreas .

This property only makes sense if the toolbar is in a QMainWindow .

See also

movable

PySide6.QtWidgets.QToolBar.allowedAreasChanged(allowedAreas)
Parameters

allowedAreasToolBarAreas

PySide6.QtWidgets.QToolBar.clear()

Removes all actions from the toolbar.

See also

removeAction()

PySide6.QtWidgets.QToolBar.iconSize()
Return type

PySide6.QtCore.QSize

This property holds size of icons in the toolbar..

The default size is determined by the application’s style and is derived from the PM_ToolBarIconSize pixel metric. It is the maximum size an icon can have. Icons of smaller size will not be scaled up.

PySide6.QtWidgets.QToolBar.iconSizeChanged(iconSize)
Parameters

iconSizePySide6.QtCore.QSize

PySide6.QtWidgets.QToolBar.initStyleOption(option)
Parameters

optionPySide6.QtWidgets.QStyleOptionToolBar

PySide6.QtWidgets.QToolBar.insertSeparator(before)
Parameters

beforePySide6.QtGui.QAction

Return type

PySide6.QtGui.QAction

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

See also

addSeparator()

PySide6.QtWidgets.QToolBar.insertWidget(before, widget)
Parameters
Return type

PySide6.QtGui.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.

See also

addWidget()

PySide6.QtWidgets.QToolBar.isAreaAllowed(area)
Parameters

areaToolBarArea

Return type

bool

Returns true if this toolbar is dockable in the given area; otherwise returns false.

PySide6.QtWidgets.QToolBar.isFloatable()
Return type

bool

This property holds whether the toolbar can be dragged and dropped as an independent window..

The default is true.

PySide6.QtWidgets.QToolBar.isFloating()
Return type

bool

This property holds whether the toolbar is an independent window..

By default, this property is true.

See also

isWindow()

PySide6.QtWidgets.QToolBar.isMovable()
Return type

bool

This property holds whether the user can move the toolbar within the toolbar area, or between toolbar areas..

By default, this property is true.

This property only makes sense if the toolbar is in a QMainWindow .

See also

allowedAreas

PySide6.QtWidgets.QToolBar.movableChanged(movable)
Parameters

movable – bool

PySide6.QtWidgets.QToolBar.orientation()
Return type

Orientation

This property holds orientation of the toolbar.

The default is Horizontal .

This function should not be used when the toolbar is managed by QMainWindow . You can use addToolBar() or insertToolBar() if you wish to move a toolbar that is already added to a main window to another ToolBarArea .

PySide6.QtWidgets.QToolBar.orientationChanged(orientation)
Parameters

orientationOrientation

PySide6.QtWidgets.QToolBar.setAllowedAreas(areas)
Parameters

areasToolBarAreas

This property holds areas where the toolbar may be placed.

The default is AllToolBarAreas .

This property only makes sense if the toolbar is in a QMainWindow .

See also

movable

PySide6.QtWidgets.QToolBar.setFloatable(floatable)
Parameters

floatable – bool

This property holds whether the toolbar can be dragged and dropped as an independent window..

The default is true.

PySide6.QtWidgets.QToolBar.setIconSize(iconSize)
Parameters

iconSizePySide6.QtCore.QSize

This property holds size of icons in the toolbar..

The default size is determined by the application’s style and is derived from the PM_ToolBarIconSize pixel metric. It is the maximum size an icon can have. Icons of smaller size will not be scaled up.

PySide6.QtWidgets.QToolBar.setMovable(movable)
Parameters

movable – bool

This property holds whether the user can move the toolbar within the toolbar area, or between toolbar areas..

By default, this property is true.

This property only makes sense if the toolbar is in a QMainWindow .

See also

allowedAreas

PySide6.QtWidgets.QToolBar.setOrientation(orientation)
Parameters

orientationOrientation

This property holds orientation of the toolbar.

The default is Horizontal .

This function should not be used when the toolbar is managed by QMainWindow . You can use addToolBar() or insertToolBar() if you wish to move a toolbar that is already added to a main window to another ToolBarArea .

PySide6.QtWidgets.QToolBar.setToolButtonStyle(toolButtonStyle)
Parameters

toolButtonStyleToolButtonStyle

This property holds the style of toolbar buttons.

This property defines the style of all tool buttons that are added as QAction s. Note that if you add a QToolButton with the addWidget() method, it will not get this button style.

To have the style of toolbuttons follow the system settings, set this property to ToolButtonFollowStyle . On Unix, the user settings from the desktop environment will be used. On other platforms, ToolButtonFollowStyle means icon only.

The default is ToolButtonIconOnly .

PySide6.QtWidgets.QToolBar.toggleViewAction()
Return type

PySide6.QtGui.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.

See also

text windowTitle

PySide6.QtWidgets.QToolBar.toolButtonStyle()
Return type

ToolButtonStyle

This property holds the style of toolbar buttons.

This property defines the style of all tool buttons that are added as QAction s. Note that if you add a QToolButton with the addWidget() method, it will not get this button style.

To have the style of toolbuttons follow the system settings, set this property to ToolButtonFollowStyle . On Unix, the user settings from the desktop environment will be used. On other platforms, ToolButtonFollowStyle means icon only.

The default is ToolButtonIconOnly .

PySide6.QtWidgets.QToolBar.toolButtonStyleChanged(toolButtonStyle)
Parameters

toolButtonStyleToolButtonStyle

PySide6.QtWidgets.QToolBar.topLevelChanged(topLevel)
Parameters

topLevel – bool

PySide6.QtWidgets.QToolBar.visibilityChanged(visible)
Parameters

visible – bool

PySide6.QtWidgets.QToolBar.widgetForAction(action)
Parameters

actionPySide6.QtGui.QAction

Return type

PySide6.QtWidgets.QWidget

Returns the widget associated with the specified action.

See also

addWidget()