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, 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 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 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 ()

Destroys the object and frees any allocated resources.

void QToolBar::addSeparator ()

Adds a separator to the end of the toolbar.

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.

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.

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

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

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.


Copyright İ 1999 Troll TechTrademarks
Qt version 2.0.2