The QToolBar class provides a tool bar. More...
#include <qtoolbar.h>
Inherits QWidget.
Type | Name | READ | WRITE | Options |
---|---|---|---|---|
QString | label | label | setLabel | |
bool | hStretchable | isHorizontalStretchable | setHorizontalStretchable | |
bool | vStretchable | isVerticalStretchable | setVerticalStretchable | |
Orientation | orientation | orientation | setOrientation |
A toolbar is a panel that contains a set of controls, usually represented by small icons. Its purpose is to provide quick access to frequently used commands or options. Within a main window, the user can drag toolbars freely around and hide them with a click on the toolbar handle.
To use QToolBar, you simply create a QToolBar as child of a QMainWindow, create a number of QToolButton widgets (or other widgets) in left to right (or top to bottom) order, call addSeparator() when you want a separator, and that's all.
The application/application.cpp example does precisely this.
You may use any kind of widget within a toolbar, with QToolButton and QComboBox being the two most common ones.
Each QToolBar lives in a dock in a QMainWindow, and can optionally start a new line in its dock. Tool bars that start a new line are always positioned at the left end or top of the tool bar dock; others are placed next to the previous tool bar and word-wrapped as necessary. The main window can be resized to a smaller size than a toolbar would need to show all items. If this happens QToolbar shows a little arrow button at the right or bottom end. When clicking on that button, a popup menu is opened which shows all items of the toolbar which are outside the visible area of the mainwindow.
Usually, a toolbar gets just the space it needs. However, with setHorizontalStretchable()/setVerticalStretchable() or setStretchableWidget() you can advise the main window to expand the toolbar to fill all available width in the specified orientation.
The tool bar arranges its buttons either horizontally or vertically (see setOrientation() for details). Generally, QMainWindow will set the orientation correctly for you. The toolbar emits a signal orientationChanged() each time the orientation changes, in case some child widgets need adjustments.
To remove all items from a toolbar, you can use the clear() method.
See also QToolButton, QMainWindow, Parts of Isys on Visual Design and GUI Design Handbook: Tool Bar.
Constructs an empty tool bar in the top dock of its parent, without any label and without requiring a newline. This is mostly useless.
Constructs an empty horizontal tool bar with a parent of parent and managed by mainWindow. The label and newLine are passed straight to QMainWindow::addToolBar(). name is the object name and f is the widget flags.
This is the constructor to use if you want to create torn-off toolbars, or toolbars in the status bar.
Constructs an empty tool bar which is a child of parent and managed by parent, initially in dock, labelled and starting a new line in the dock if newLine is TRUE. name is the object name, as usual.
Destructs the object and frees any allocated resources.
Adds a separator to the end of the toolbar.
Clears the toolbar, deleting all childwidgets.
[virtual]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QObject.
[virtual]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QObject.
[virtual]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
Returns whether the toolbar is stretchable horizontally.
A stretchable toolbar fills all available width in a toolbar dock. A non-stretchable toolbar usually gets just the space it needs.
See also setHorizontalStretchable(), setVerticalStretchable() and isVerticalStretchable().
Returns whether the toolbar is stretchable vertically.
A stretchable toolbar fills all available height in a toolbar dock. A non-stretchable toolbar usually gets just the space it needs.
See also setHorizontalStretchable(), setVerticalStretchable() and isHorizontalStretchable().
Returns the label of this tool bar.
See also setLabel().
Returns a pointer to the QMainWindow which controls this tool bar.
Reimplemented for internal reasons; the API is not affected.
[virtual]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
Returns the current orientation of the toolbar.
[signal]
This signal is emitted when the toolbar changed its orientation to newOrientation.
[virtual protected]
Paint the handle. The Motif style is rather close to Netscape and even closer to KDE.
Reimplemented from QWidget.
[virtual protected]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
Sets the toolbar to be horizontally stretchable if b is TRUE, or non-stretchable otherwise.
A stretchable toolbar fills the available width in a toolbar dock. A non-stretchable toolbar usually gets just the space it needs.
The default is FALSE.
See also QMainWindow::setRightJustification(), isHorizontalStretchable(), setVerticalStretchable() and isVerticalStretchable().
[virtual]
Sets the label of this tool bar to label. The label is not currently used; it will be used in a forthcoming tool bar configuration dialog.
See also label().
[virtual]
Sets this toolbar to organize its content vertically if newOrientation is Vertical
and horizontally if newOrientation
is Horizontal.
Emits the orientationChanged() signal.
See also orientation().
[virtual]
Sets w to be expanded if this toolbar is requested to stretch (because QMainWindow right-justifies the dock it's in or isVerticalStretchable() or isHorizontalStretchable() of this toolbar is TRUE).
If you call setStretchableWidget() and the toolbar is not stretchable yet, setStretchable( ) is called.
See also QMainWindow::setRightJustification(), setVerticalStretchable() and setHorizontalStretchable().
Sets the toolbar to be vertically stretchable if b is TRUE, or non-stretchable otherwise.
A stretchable toolbar fills the available height in a toolbar dock. A non-stretchable toolbar usually gets just the space it needs.
The default is FALSE.
See also QMainWindow::setRightJustification(), isVerticalStretchable(), setHorizontalStretchable() and isHorizontalStretchable().
[virtual]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.
Copyright İ 2000 Trolltech | Trademarks | Qt version 2.2.1
|