Qt Toolkit - QToolBar Class

# QToolBar Class Reference

The QToolBar class provides a simple tool bar. More...

`#include <qtoolbar.h>`

Inherits QWidget.

List of all member functions.

## Public Members

- QToolBar ( const char * label, QMainWindow *, QMainWindow::ToolBarDock = QMainWindow::Top, bool newLine = FALSE, const char * name = 0 )
- QToolBar ( const char * 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
- virtual void show ()
- QMainWindow* mainWindow ()
- void setStretchableWidget ( QWidget * )
- virtual bool event ( QEvent * e )

## Protected Members

- virtual void paintEvent ( QPaintEvent * )

## Detailed Description

The QToolBar class provides a simple tool bar.

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.

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 tool bar is able to arrange its buttons horizontally or vertically (see setOrientation() for details) and draws the appropriate frames around the tool button in Windows and Motif style. Generally, QMainWindow will set the orientation correctly for you.

See also: QToolButton, QMainWindow, Parts of Isys on Visual Design,, Microsoft Style Guide,, some common buttons (NB: read the license), and GUI Design Handbook: Tool Bar.

Examples: application/application.cpp

## 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 char * label, QMainWindow * mainWindow, QWidget * parent, bool newLine = FALSE, const char * name = 0, WFlags f = 0 )

Constructs an empty horizontal tool bar which is 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 char * label, QMainWindow * parent, QMainWindow::ToolBarDock dock = QMainWindow::Top, bool newLine = FALSE, const char * name = 0 )

Constructs an empty tool bar which is a chilf od 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 ()

Destroys the object and frees any allocated resources.

### void QToolBar::addSeparator ()

Adds a separator in here. Cool, man.

### bool QToolBar::event ( QEvent * e ) `[virtual]`

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QObject.

### QMainWindow * QToolBar::mainWindow ()

Returns a pointer to the QMainWindow which controls this tool bar.

### QToolBar::Orientation QToolBar::orientation() const

Returns the current orientation of the toolbar.

### 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::setOrientation ( Orientation newOrientation ) `[virtual]`

Sets this toolbar to organize its content vertically if newOrientation is `Vertical` and horizontally if newOrientation is `Horizontal.`

### void QToolBar::setStretchableWidget ( QWidget * w )

Sets w to be expanded if this toolbar is requested to stretch (because QMainWindow right-justifies the dock it's in).

### void QToolBar::show () `[virtual]`

Reimplemented to set up geometry management.

Reimplemented from QWidget.

Search the documentation, FAQ, qt-interest archive and more (uses www.troll.no):

This file is part of the Qt toolkit, copyright © 1995-99 Troll Tech, all rights reserved.

It was generated from the following files:

- qtoolbar.h: 1998/08/19
- qtoolbar.cpp: 1998/08/12