PySide6.QtWidgets.QToolBar¶
- class 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
Methods¶
def
__init__()
def
actionAt()
def
actionGeometry()
def
addSeparator()
def
addWidget()
def
allowedAreas()
def
clear()
def
iconSize()
def
insertWidget()
def
isAreaAllowed()
def
isFloatable()
def
isFloating()
def
isMovable()
def
orientation()
def
setFloatable()
def
setMovable()
def
setOrientation()
Virtual methods¶
Slots¶
def
setIconSize()
Signals¶
def
movableChanged()
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¶
A toolbar is typically created by calling
addToolBar(const QString &title)
, but it can also be added as the first widget in aQVBoxLayout
, for example.Toolbar buttons are added by adding actions, using
addAction()
orinsertAction()
. Groups of buttons can be separated usingaddSeparator()
orinsertSeparator()
. If a toolbar button is not appropriate, a widget can be inserted instead usingaddWidget()
orinsertWidget()
. Examples of suitable widgets areQSpinBox
,QDoubleSpinBox
, andQComboBox
. When a toolbar button is pressed, it emits theactionTriggered()
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()
andisAreaAllowed()
.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 aQMainWindow
, it loses the ability to populate the extension pop up with widgets added to the toolbar usingaddWidget()
. Please use widget actions created by inheritingQWidgetAction
and implementingcreateWidget()
instead.See also
Note
Properties can be used directly when
from __feature__ import true_property
is used or via accessor functions otherwise.- property allowedAreasᅟ: Combination of Qt.ToolBarArea¶
This property holds areas where the toolbar may be placed.
The default is Qt::AllToolBarAreas.
This property only makes sense if the toolbar is in a
QMainWindow
.See also
movable
- Access functions:
- property floatableᅟ: bool¶
This property holds whether the toolbar can be dragged and dropped as an independent window..
The default is true.
- Access functions:
- property floatingᅟ: bool¶
This property holds whether the toolbar is an independent window..
By default, this property is
true
.See also
- Access functions:
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:
- property 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:
- property orientationᅟ: Qt.Orientation¶
This property holds orientation of the toolbar.
The default is Qt::Horizontal.
This function should not be used when the toolbar is managed by
QMainWindow
. You can useaddToolBar()
orinsertToolBar()
if you wish to move a toolbar that is already added to a main window to another Qt::ToolBarArea.- Access functions:
- property toolButtonStyleᅟ: Qt.ToolButtonStyle¶
This property holds the style of toolbar buttons.
This property defines the style of all tool buttons that are added as QActions. Note that if you add a
QToolButton
with theaddWidget()
method, it will not get this button style.To have the style of toolbuttons follow the system settings, set this property to Qt::ToolButtonFollowStyle. On Unix, the user settings from the desktop environment will be used. On other platforms, Qt::ToolButtonFollowStyle means icon only.
The default is Qt::ToolButtonIconOnly.
- Access functions:
Constructs a
QToolBar
with the givenparent
.- __init__(title[, parent=None])
- Parameters:
title – str
parent –
QWidget
Constructs a
QToolBar
with the givenparent
.The given window
title
identifies the toolbar and is shown in the context menu provided byQMainWindow
.See also
Returns the action at point
p
. This function returns zero if no action was found.See also
- 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.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
.Adds a separator to the end of the toolbar.
See also
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 Qt::ToolButtonStyle will not be respected.Note
You should use QAction::setVisible() to change the visibility of the widget. Using
setVisible()
,show()
andhide()
does not work.See also
- allowedAreas()¶
- Return type:
Combination of
ToolBarArea
See also
Getter of property
allowedAreasᅟ
.- allowedAreasChanged(allowedAreas)¶
- Parameters:
allowedAreas – Combination of
ToolBarArea
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ᅟ
.- clear()¶
Removes all actions from the toolbar.
See also
- iconSize()¶
- Return type:
See also
Getter of property
iconSizeᅟ
.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ᅟ
.- initStyleOption(option)¶
- Parameters:
option –
QStyleOptionToolBar
Inserts a separator into the toolbar in front of the toolbar item associated with the
before
action.See also
Inserts the given
widget
in front of the toolbar item associated with thebefore
action.Note: You should use QAction::setVisible() to change the visibility of the widget. Using
setVisible()
,show()
andhide()
does not work.See also
- isAreaAllowed(area)¶
- Parameters:
area –
ToolBarArea
- Return type:
bool
Returns
true
if this toolbar is dockable in the givenarea
; otherwise returnsfalse
.- isFloatable()¶
- Return type:
bool
Getter of property
floatableᅟ
.- isFloating()¶
- Return type:
bool
Getter of property
floatingᅟ
.- isMovable()¶
- Return type:
bool
Getter of property
movableᅟ
.- 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ᅟ
.- orientation()¶
- Return type:
See also
Getter of property
orientationᅟ
.- 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ᅟ
.- setAllowedAreas(areas)¶
- Parameters:
areas – Combination of
ToolBarArea
See also
Setter of property
allowedAreasᅟ
.- setFloatable(floatable)¶
- Parameters:
floatable – bool
See also
Setter of property
floatableᅟ
.Setter of property
iconSizeᅟ
.- setMovable(movable)¶
- Parameters:
movable – bool
See also
Setter of property
movableᅟ
.- setOrientation(orientation)¶
- Parameters:
orientation –
Orientation
See also
Setter of property
orientationᅟ
.- setToolButtonStyle(toolButtonStyle)¶
- Parameters:
toolButtonStyle –
ToolButtonStyle
See also
Setter of property
toolButtonStyleᅟ
.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
- toolButtonStyle()¶
- Return type:
See also
Getter of property
toolButtonStyleᅟ
.- 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ᅟ
.- topLevelChanged(topLevel)¶
- Parameters:
topLevel – bool
This signal is emitted when the
floating
property changes. ThetopLevel
parameter is true if the toolbar is now floating; otherwise it is false.See also
- 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.Returns the widget associated with the specified
action
.See also