
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQ3ToolBar class provides a movable panel containing widgets such as tool buttons.More...
| Header: | #include <Q3ToolBar> |
| Inherits: | Q3DockWindow |
| Q3ToolBar(const QString & label, Q3MainWindow * parent, Qt::ToolBarDock dock = Qt::DockTop, bool newLine = false, const char * name = 0) | |
| Q3ToolBar(const QString & label, Q3MainWindow * mainWindow, QWidget * parent, bool newLine = false, const char * name = 0, Qt::WindowFlags f = 0) | |
| Q3ToolBar(Q3MainWindow * parent = 0, const char * name = 0) | |
| ~Q3ToolBar() | |
| void | addSeparator() |
| virtual void | clear() |
| QString | label() const |
| Q3MainWindow * | mainWindow() const |
| virtual void | setLabel(const QString &) |
| virtual void | setStretchableWidget(QWidget * w) |
| virtual bool | event(QEvent * e) |
| virtual QSize | minimumSizeHint() const |
| virtual void | setOrientation(Qt::Orientation o) |
| virtual void | setVisible(bool visible) |
| virtual void | resizeEvent(QResizeEvent * e) |
TheQ3ToolBar class provides a movable panel containing widgets such as tool buttons.
A toolbar is a panel that contains a set of controls, usually represented by small icons. It's purpose is to provide quick access to frequently used commands or options. Within aQ3MainWindow the user can drag toolbars within and between thedock areas. Toolbars can also be dragged out of any dock area to float freely as top-level windows.
Q3ToolBar is a specialization ofQDockWindow, and so provides all the functionality of aQDockWindow.
To useQ3ToolBar you simply create aQ3ToolBar as a child of aQ3MainWindow, create a number ofQToolButton widgets (or other widgets) in left to right (or top to bottom) order and calladdSeparator() when you want a separator. When a toolbar is floated the caption used is the label given in the constructor call. This can be changed withsetLabel().
You may use most widgets within a toolbar, withQToolButton andQComboBox being the most common. But note that the toolbar's actions must beQ3Actions.
If you create a new widget on an already visibleQ3ToolBar, this widget will automatically become visible without needing ashow() call. (This differs from every other Qt widget container. We recommend callingshow() anyway since we hope to fix this anomaly in a future release.)
Q3ToolBars, like QDockWindows, are located inQ3DockAreas or float as top-level windows.Q3MainWindow provides four Q3DockAreas (top, left, right and bottom). When you create a new toolbar (as in the example above) as a child of aQ3MainWindow the toolbar will be added to the top dock area. You can move it to another dock area (or float it) by callingQ3MainWindow::moveDockWindow(). Dock areas lay out their windows in lines.
If the main window is resized so that the area occupied by the toolbar is too small to show all its widgets a little arrow button (which looks like a right-pointing chevron, '»') will appear at the right or bottom of the toolbar depending on its orientation. Clicking this button pops up a menu that shows the 'overflowing' items. QToolButtons are represented in the menu using their textLabel property, otherQAbstractButton subclasses are represented using their text property, and QComboBoxes are represented as submenus, with the caption text being used in the submenu item.
Usually a toolbar will get precisely the space it needs. However, withsetHorizontalStretchable(),setVerticalStretchable() orsetStretchableWidget() you can tell the main window to expand the toolbar to fill all available space in the specified orientation.
The toolbar arranges its buttons either horizontally or vertically (seeorientation() for details). Generally,Q3DockArea will set the orientation correctly for you, but you can set it yourself withsetOrientation() and track any changes by connecting to theorientationChanged() signal.
You can use theclear() method to remove all items from a toolbar.

A floatingQToolbar (dock window)
See alsoQToolButton andQ3MainWindow.
This property holds the toolbar's label.
If the toolbar is floated the label becomes the toolbar window's caption. There is no default label text.
Access functions:
| QString | label() const |
| virtual void | setLabel(const QString &) |
Constructs an empty toolbar.
The toolbar is calledname and is a child ofparent and is managed byparent. It is initially located in dock areadock and is labeledlabel. IfnewLine is true the toolbar will be placed on a new line in the dock area.
Constructs an empty horizontal toolbar.
The toolbar is calledname and is a child ofparent and is managed bymainWindow. Thelabel andnewLine parameters are passed straight toQ3MainWindow::addDockWindow().name and the widget flagsf are passed on to theQ3DockWindow constructor.
Use this constructor if you want to create torn-off (undocked, floating) toolbars or toolbars in thestatus bar.
This is an overloaded function.
Constructs an empty toolbar calledname, with parentparent, in itsparent's top dock area, without any label and without requiring a newline.
Destructor.
Adds a separator to the right/bottom of the toolbar.
[virtual]void Q3ToolBar::clear()Deletes all the toolbar's child widgets.
[virtual]bool Q3ToolBar::event(QEvent * e)Reimplemented fromQObject::event().
Returns a pointer to theQ3MainWindow which manages this toolbar.
[virtual]QSize Q3ToolBar::minimumSizeHint() constReimplemented fromQWidget::minimumSizeHint().
[virtual protected]void Q3ToolBar::resizeEvent(QResizeEvent * e)Reimplemented fromQWidget::resizeEvent().
[virtual]void Q3ToolBar::setOrientation(Qt::Orientation o)Reimplemented fromQ3DockWindow::setOrientation().
[virtual]void Q3ToolBar::setStretchableWidget(QWidget * w)Sets the widgetw to be expanded if this toolbar is requested to stretch.
The request to stretch might occur becauseQ3MainWindow right-justifies the dock area the toolbar is in, or because this toolbar'sisVerticalStretchable() orisHorizontalStretchable() is set to true.
If you call this function and the toolbar is not yet stretchable, setStretchable() is called.
See alsoQ3MainWindow::setRightJustification(),setVerticalStretchable(), andsetHorizontalStretchable().
[virtual]void Q3ToolBar::setVisible(bool visible)Reimplemented fromQWidget::setVisible().
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.