QToolBar(3qt)

NAME
QToolBar - Tool bar

#include <qtoolbar.h>

Inherits QWidget.

  Public Members
QToolBar ( const QString & label, QMainWindow *, QMainWindow::ToolBarDock = QMainWindow::Top, bool newLine = FALSE, const char * name = 0 )
QToolBar ( const QString & label, QMainWindow *, QWidget *, bool newLine = FALSE, const char * name = 0, WFlags f = 0 )
QToolBar ( QMainWindow * parent = 0, const char * name = 0 )
~QToolBar ()
void addSeparator ()
virtual void setOrientation ( Orientation )
Orientation orientation () const
QMainWindow* mainWindow ()
virtual void setStretchableWidget ( QWidget * )
void setHorizontalStretchable ( bool b )
void setVerticalStretchable ( bool b )
bool isHorizontalStretchable () const
bool isVerticalStretchable () const
virtual void setLabel ( const QString & )
QString label () const
void clear ()

  Signals
void orientationChanged ( Orientation )

  Protected Members
virtual void paintEvent ( QPaintEvent * )

  Properties
Type | Name | READ | WRITE | Options
QString | label | label | setLabel
bool | hStretchable | isHorizontalStretchable | setHorizontalStretchable
bool | vStretchable | isVerticalStretchable | setVerticalStretchable
Orientation | orientation | orientation | setOrientation

DESCRIPTION
The QToolBar class provides a tool bar.

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.

MEMBER FUNCTION DOCUMENTATION

QToolBar::QToolBar ( QMainWindow * parent = 0, const char * name = 0 )
Constructs an empty tool bar in the top dock of its parent, without any label and without requiring a newline. This is mostly useless.

QToolBar::QToolBar ( const QString & label, QMainWindow * mainWindow, QWidget * parent, bool newLine = FALSE, const char * name = 0, WFlags f = 0 )
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.

QToolBar::QToolBar ( const QString & label, QMainWindow * parent, QMainWindow::ToolBarDock dock = QMainWindow::Top, bool newLine = FALSE, const char * name = 0 )
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.

QToolBar::~QToolBar ()
Destructs the object and frees any allocated resources.

void QToolBar::addSeparator ()
Adds a separator to the end of the toolbar.

void QToolBar::clear ()
Clears the toolbar, deleting all childwidgets.

bool QToolBar::event ( QEvent * e ) [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QObject.

bool QToolBar::eventFilter ( QObject * obj, QEvent * e ) [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QObject.

void QToolBar::hide () [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

bool QToolBar::isHorizontalStretchable () const
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().

bool QToolBar::isVerticalStretchable () const
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().

QString QToolBar::label () const
Returns the label of this tool bar.

See also setLabel().

QMainWindow * QToolBar::mainWindow ()
Returns a pointer to the QMainWindow which controls this tool bar.

QSize QToolBar::minimumSize () const
Reimplemented for internal reasons; the API is not affected.

QSize QToolBar::minimumSizeHint () const [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

Orientation QToolBar::orientation () const
Returns the current orientation of the toolbar.

void QToolBar::orientationChanged ( Orientation newOrientation ) [signal]
This signal is emitted when the toolbar changed its orientation to newOrientation.

void QToolBar::paintEvent ( QPaintEvent * ) [virtual protected]
Paint the handle. The Motif style is rather close to Netscape and even closer to KDE.

Reimplemented from QWidget.

void QToolBar::resizeEvent ( QResizeEvent * e ) [virtual protected]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QToolBar::setHorizontalStretchable ( bool b )
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().

void QToolBar::setLabel ( const QString & label ) [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().

void QToolBar::setOrientation ( Orientation newOrientation ) [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().

void QToolBar::setStretchableWidget ( QWidget * w ) [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().

void QToolBar::setVerticalStretchable ( bool b )
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().

void QToolBar::show () [virtual]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

void QToolBar::styleChange ( QStyle & ) [virtual protected]
Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

SEE ALSO
http://doc.trolltech.com/qtoolbar.html http://www.trolltech.com/faq/tech.html

COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.

BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports make our job much simpler. Thank you.

In case of content or formattting problems with this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qtoolbar.3qt) and the Qt version (2.3.5).