QToolBar#
The QToolBar
class provides a movable panel that contains a set of controls. More…
Synopsis#
Properties#
allowedAreas
- Areas where the toolbar may be placedfloatable
- Whether the toolbar can be dragged and dropped as an independent windowfloating
- Whether the toolbar is an independent windowiconSize
- Size of icons in the toolbarmovable
- Whether the user can move the toolbar within the toolbar area, or between toolbar areasorientation
- Of the toolbartoolButtonStyle
- The style of toolbar buttons
Functions#
def
actionAt
(x, y)def
actionAt
(p)def
actionGeometry
(action)def
addSeparator
()def
addWidget
(widget)def
allowedAreas
()def
clear
()def
iconSize
()def
insertSeparator
(before)def
insertWidget
(before, widget)def
isAreaAllowed
(area)def
isFloatable
()def
isFloating
()def
isMovable
()def
orientation
()def
setAllowedAreas
(areas)def
setFloatable
(floatable)def
setMovable
(movable)def
setOrientation
(orientation)def
toggleViewAction
()def
toolButtonStyle
()def
widgetForAction
(action)
Virtual functions#
def
initStyleOption
(option)
Slots#
def
setIconSize
(iconSize)def
setToolButtonStyle
(toolButtonStyle)
Signals#
def
actionTriggered
(action)def
allowedAreasChanged
(allowedAreas)def
iconSizeChanged
(iconSize)def
movableChanged
(movable)def
orientationChanged
(orientation)def
toolButtonStyleChanged
(toolButtonStyle)def
topLevelChanged
(topLevel)def
visibilityChanged
(visible)
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
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.
See also
QToolButton
QMenu
QAction
Qt Widgets - Application Example
- class PySide6.QtWidgets.QToolBar([parent=None])#
PySide6.QtWidgets.QToolBar(title[, parent=None])
- Parameters:
parent –
PySide6.QtWidgets.QWidget
title – str
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
Note
Properties can be used directly when from __feature__ import true_property
is used or via accessor functions otherwise.
- property PᅟySide6.QtWidgets.QToolBar.allowedAreas: 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
- Access functions:
allowedAreas
()setAllowedAreas
(areas)Signal
allowedAreasChanged
(allowedAreas)
- property PᅟySide6.QtWidgets.QToolBar.floatable: bool#
This property holds whether the toolbar can be dragged and dropped as an independent window..
The default is true.
- Access functions:
isFloatable
()setFloatable
(floatable)
- property PᅟySide6.QtWidgets.QToolBar.floating: bool#
This property holds whether the toolbar is an independent window..
By default, this property is true
.
See also
- Access functions:
isFloating
()
- property PᅟySide6.QtWidgets.QToolBar.iconSize: 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.
- Access functions:
iconSize
()setIconSize
(iconSize)Signal
iconSizeChanged
(iconSize)
- property PᅟySide6.QtWidgets.QToolBar.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
- Access functions:
isMovable
()setMovable
(movable)Signal
movableChanged
(movable)
- property PᅟySide6.QtWidgets.QToolBar.orientation: 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
.
- Access functions:
orientation
()setOrientation
(orientation)Signal
orientationChanged
(orientation)
- property PᅟySide6.QtWidgets.QToolBar.toolButtonStyle: 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
.
- Access functions:
setToolButtonStyle
(toolButtonStyle)Signal
toolButtonStyleChanged
(toolButtonStyle)
- PySide6.QtWidgets.QToolBar.actionAt(x, y)#
- Parameters:
x – int
y – int
- Return type:
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.actionAt(p)
- Parameters:
- Return type:
Returns the action at point p
. This function returns zero if no action was found.
See also
- PySide6.QtWidgets.QToolBar.actionGeometry(action)#
- Parameters:
action –
PySide6.QtGui.QAction
- Return type:
- PySide6.QtWidgets.QToolBar.actionTriggered(action)#
- Parameters:
action –
PySide6.QtGui.QAction
This signal is emitted when an action in this toolbar is triggered. This happens when the action’s tool button is pressed, or when the action is triggered in some other way outside the toolbar. The parameter holds the triggered action
.
- PySide6.QtWidgets.QToolBar.addSeparator()#
- Return type:
Adds a separator to the end of the toolbar.
See also
- PySide6.QtWidgets.QToolBar.addWidget(widget)#
- Parameters:
widget –
PySide6.QtWidgets.QWidget
- Return type:
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
- PySide6.QtWidgets.QToolBar.allowedAreas()#
- Return type:
ToolBarAreas
See also
Getter of property allowedAreas
.
- PySide6.QtWidgets.QToolBar.allowedAreasChanged(allowedAreas)#
- Parameters:
allowedAreas –
ToolBarAreas
This signal is emitted when the collection of allowed areas for the toolbar is changed. The new areas in which the toolbar can be positioned are specified by allowedAreas
.
See also
Notification signal of property allowedAreas
.
- PySide6.QtWidgets.QToolBar.clear()#
Removes all actions from the toolbar.
See also
- PySide6.QtWidgets.QToolBar.iconSize()#
- Return type:
See also
Getter of property iconSize
.
- PySide6.QtWidgets.QToolBar.iconSizeChanged(iconSize)#
- Parameters:
iconSize –
PySide6.QtCore.QSize
This signal is emitted when the icon size is changed. The iconSize
parameter holds the toolbar’s new icon size.
Notification signal of property iconSize
.
- PySide6.QtWidgets.QToolBar.initStyleOption(option)#
- Parameters:
- PySide6.QtWidgets.QToolBar.insertSeparator(before)#
- Parameters:
before –
PySide6.QtGui.QAction
- Return type:
Inserts a separator into the toolbar in front of the toolbar item associated with the before
action.
See also
- PySide6.QtWidgets.QToolBar.insertWidget(before, widget)#
- Parameters:
before –
PySide6.QtGui.QAction
widget –
PySide6.QtWidgets.QWidget
- Return type:
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
- PySide6.QtWidgets.QToolBar.isAreaAllowed(area)#
- Parameters:
area –
ToolBarArea
- Return type:
bool
Returns true
if this toolbar is dockable in the given area
; otherwise returns false
.
- PySide6.QtWidgets.QToolBar.isFloatable()#
- Return type:
bool
Getter of property floatable
.
- PySide6.QtWidgets.QToolBar.isFloating()#
- Return type:
bool
Getter of property floating
.
- PySide6.QtWidgets.QToolBar.isMovable()#
- Return type:
bool
Getter of property movable
.
- PySide6.QtWidgets.QToolBar.movableChanged(movable)#
- Parameters:
movable – bool
This signal is emitted when the toolbar becomes movable or fixed. If the toolbar can be moved, movable
is true; otherwise it is false.
See also
movable
Notification signal of property movable
.
- PySide6.QtWidgets.QToolBar.orientation()#
- Return type:
See also
Getter of property orientation
.
- PySide6.QtWidgets.QToolBar.orientationChanged(orientation)#
- Parameters:
orientation –
Orientation
This signal is emitted when the orientation of the toolbar changes. The orientation
parameter holds the toolbar’s new orientation.
See also
Notification signal of property orientation
.
- PySide6.QtWidgets.QToolBar.setAllowedAreas(areas)#
- Parameters:
areas –
ToolBarAreas
See also
Setter of property allowedAreas
.
- PySide6.QtWidgets.QToolBar.setFloatable(floatable)#
- Parameters:
floatable – bool
See also
Setter of property floatable
.
- PySide6.QtWidgets.QToolBar.setIconSize(iconSize)#
- Parameters:
iconSize –
PySide6.QtCore.QSize
See also
Setter of property iconSize
.
- PySide6.QtWidgets.QToolBar.setMovable(movable)#
- Parameters:
movable – bool
See also
Setter of property movable
.
- PySide6.QtWidgets.QToolBar.setOrientation(orientation)#
- Parameters:
orientation –
Orientation
See also
Setter of property orientation
.
- PySide6.QtWidgets.QToolBar.setToolButtonStyle(toolButtonStyle)#
- Parameters:
toolButtonStyle –
ToolButtonStyle
See also
Setter of property toolButtonStyle
.
- PySide6.QtWidgets.QToolBar.toggleViewAction()#
- Return type:
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:
See also
Getter of property toolButtonStyle
.
- PySide6.QtWidgets.QToolBar.toolButtonStyleChanged(toolButtonStyle)#
- Parameters:
toolButtonStyle –
ToolButtonStyle
This signal is emitted when the tool button style is changed. The toolButtonStyle
parameter holds the toolbar’s new tool button style.
See also
Notification signal of property toolButtonStyle
.
- PySide6.QtWidgets.QToolBar.topLevelChanged(topLevel)#
- Parameters:
topLevel – bool
This signal is emitted when the floating
property changes. The topLevel
parameter is true if the toolbar is now floating; otherwise it is false.
See also
- PySide6.QtWidgets.QToolBar.visibilityChanged(visible)#
- Parameters:
visible – bool
This signal is emitted when the toolbar becomes visible
(or invisible). This happens when the widget is hidden or shown.
- PySide6.QtWidgets.QToolBar.widgetForAction(action)#
- Parameters:
action –
PySide6.QtGui.QAction
- Return type:
Returns the widget associated with the specified action
.
See also