Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions

TQToolBar Class Reference

The TQToolBar class provides a movable panel containing widgets such as tool buttons. More...

#include <qtoolbar.h>

Inherits TQDockWindow.

List of all member functions.

Public Members

Properties


Detailed Description

The TQToolBar class provides a movable panel containing widgets such as tool buttons.

A toolbar is a panel that contains a set of controls, usually represented by small icons. It's purpose is to provide tquick access to frequently used commands or options. Within a TQMainWindow the user can drag toolbars within and between the dock areas. Toolbars can also be dragged out of any dock area to float freely as top-level windows.

TQToolBar is a specialization of TQDockWindow, and so provides all the functionality of a TQDockWindow.

To use TQToolBar you simply create a TQToolBar as a child of a TQMainWindow, create a number of TQToolButton widgets (or other widgets) in left to right (or top to bottom) order and call addSeparator() when you want a separator. When a toolbar is floated the caption used is the label given in the constructor call. This can be changed with setLabel().

        TQToolBar * fileTools = new TQToolBar( this, "file operations" );
        fileTools->setLabel( "File Operations" );
        fileOpenAction->addTo( fileTools );
        fileSaveAction->addTo( fileTools );

This extract from the application/application.cpp example shows the creation of a new toolbar as a child of a TQMainWindow and adding two TQActions.

You may use most widgets within a toolbar, with TQToolButton and TQComboBox being the most common.

If you create a new widget on an already visible TQToolBar, this widget will automatically become visible without needing a show() call. (This differs from every other TQt widget container. We recommend calling show() anyway since we hope to fix this anomaly in a future release.)

TQToolBars, like TQDockWindows, are located in TQDockAreas or float as top-level windows. TQMainWindow provides four TQDockAreas (top, left, right and bottom). When you create a new toolbar (as in the example above) as a child of a TQMainWindow the toolbar will be added to the top dock area. You can move it to another dock area (or float it) by calling TQMainWindow::moveDockWindow(). TQDock areas lay out their windows in Lines.

If the main window is resized so that the area occupied by the toolbar is too small to show all its widgets a little arrow button (which looks like a right-pointing chevron, '»') will appear at the right or bottom of the toolbar depending on its orientation. Clicking this button pops up a menu that shows the 'overflowing' items. TQToolButtons are represented in the menu using their textLabel property, other TQButton subclasses are represented using their text property, and TQComboBoxes are represented as submenus, with the caption text being used in the submenu item.

Usually a toolbar will get precisely the space it needs. However, with setHorizontalStretchable(), setVerticalStretchable() or setStretchableWidget() you can tell the main window to expand the toolbar to fill all available space in the specified orientation.

The toolbar arranges its buttons either horizontally or vertically (see orientation() for details). Generally, TQDockArea will set the orientation correctly for you, but you can set it yourself with setOrientation() and track any changes by connecting to the orientationChanged() signal.

You can use the clear() method to remove all items from a toolbar.

Toolbar (dock window)

A floating TQToolbar (dock window)

See also TQToolButton, TQMainWindow, Parts of Isys on Visual Design, GUI Design Handbook: Tool Bar, and Main Window and Related Classes.


Member Function Documentation

TQToolBar::TQToolBar ( const TQString & label, TQMainWindow *, ToolBarDock = DockTop, bool newLine = FALSE, const char * name = 0 )

This function is obsolete. It is provided to keep old source working. We strongly advise against using it in new code.

TQToolBar::TQToolBar ( const TQString & label, TQMainWindow * mainWindow, TQWidget * parent, bool newLine = FALSE, const char * name = 0, WFlags f = 0 )

Constructs an empty horizontal toolbar.

The toolbar is called name and is a child of parent and is managed by mainWindow. The label and newLine parameters are passed straight to TQMainWindow::addDockWindow(). name and the widget flags f are passed on to the TQDockWindow constructor.

Use this constructor if you want to create torn-off (undocked, floating) toolbars or toolbars in the status bar.

TQToolBar::TQToolBar ( TQMainWindow * parent = 0, const char * name = 0 )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Constructs an empty toolbar called name, with parent parent, in its parent's top dock area, without any label and without retquiring a newline.

void TQToolBar::addSeparator ()

Adds a separator to the right/bottom of the toolbar.

Examples: chart/chartform.cpp, fileiconview/mainwindow.cpp, helpviewer/helpwindow.cpp, qfd/fontdisplayer.cpp, and scribble/scribble.cpp.

void TQToolBar::clear () [virtual]

Deletes all the toolbar's child widgets.

TQString TQToolBar::label () const

Returns the toolbar's label. See the "label" property for details.

TQMainWindow * TQToolBar::mainWindow () const

Returns a pointer to the TQMainWindow which manages this toolbar.

void TQToolBar::setLabel ( const TQString & ) [virtual]

Sets the toolbar's label. See the "label" property for details.

void TQToolBar::setStretchableWidget ( TQWidget * w ) [virtual]

Sets the widget w to be expanded if this toolbar is requested to stretch.

The request to stretch might occur because TQMainWindow right-justifies the dock area the toolbar is in, or because this toolbar's isVerticalStretchable() or isHorizontalStretchable() is set to TRUE.

If you call this function and the toolbar is not yet stretchable, setStretchable() is called.

See also TQMainWindow::rightJustification, setVerticalStretchable(), and setHorizontalStretchable().

Examples: fileiconview/mainwindow.cpp and helpviewer/helpwindow.cpp.


Property Documentation

TQString label

This property holds the toolbar's label.

If the toolbar is floated the label becomes the toolbar window's caption. There is no default label text.

Set this property's value with setLabel() and get this property's value with label().


This file is part of the TQt toolkit. Copyright © 1995-2007 Trolltech. All Rights Reserved.


Copyright © 2007 TrolltechTrademarks
TQt 3.3.8