Qt logo

QToolBar Class Reference

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

#include <qtoolbar.h>

Inherits QWidget.

List of all member functions.

Public Members

Protected Members

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.

Member Function Documentation

QToolBar::QToolBar(QMainWindow*parent=0, constchar*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(constQString&label, QMainWindow*mainWindow, QWidget*parent, boolnewLine=FALSE, constchar*name=0, WFlagsf=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(constQString&label, QMainWindow*parent, QMainWindow::ToolBarDockdock=QMainWindow::Top, boolnewLine=FALSE, constchar*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.


Destroys the object and frees any allocated resources.


Adds a separator to the end of the toolbar.

boolQToolBar::event(QEvent*e) [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QObject.

boolQToolBar::eventFilter(QObject*obj, QEvent*e) [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QObject.


Returns the label of this tool bar.

See also: setLabel().


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


Returns the current orientation of the toolbar.

voidQToolBar::paintEvent(QPaintEvent*) [virtualprotected]

Paint the handle. The Motif style is rather close to Netscape and even closer to KDE.

Reimplemented from QWidget.

voidQToolBar::setLabel(constQString&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().

voidQToolBar::setOrientation(OrientationnewOrientation) [virtual]

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

voidQToolBar::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).

voidQToolBar::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.

Copyright 1999 Troll TechTrademarks
Qt version 2.0.2