Qt logo

QToolButton Class Reference


The QToolButton class provides a push button whose appearance has been tailored for use in a QToolBar. More...

#include <qtoolbutton.h>

Inherits QButton.

List of all member functions.

Public Members

Public Slots

Protected Members


Detailed Description

The QToolButton class provides a push button whose appearance has been tailored for use in a QToolBar.

This means that it implements the ridiculous Microsoft auto-raise feature using QIconSet. Apart from that, it's pretty much like a QPushButton. The two classes may at some point be merged.

See also: QPushButton, QToolButton and GUI Design Handbook: Push Button


Member Function Documentation

QToolButton::QToolButton(QWidget*parent, constchar*name=0)

Constructs an empty tool button.

QToolButton::QToolButton(constQIconSet&iconSet, constQString&textLabel, constQString&grouptext, QObject*receiver, constchar*slot, QToolBar*parent, constchar*name=0)

Creates a tool button that is a child of parent (which must be a QToolBar) and named name.

The tool button will display iconSet, with text label or tool tip textLabel and status-bar message grouptext, connected to slot in object receiver, and returns the button.

QToolButton::QToolButton(constQPixmap&pm, constQString&textLabel, constQString&grouptext, QObject*receiver, constchar*slot, QToolBar*parent, constchar*name=0)

Creates a tool button that is a child of parent (which must be a QToolBar) and named name.

The tool button will display pm, with text label or tool tip textLabel and status-bar message grouptext, connected to slot in object receiver, and returns the button.

QToolButton::~QToolButton()

Destroys the object and frees any allocated resources.

voidQToolButton::drawButton(QPainter*p) [virtualprotected]

Draws the edges and decoration of the button (pretty much nothing) and calls drawButtonLabel().

See also: drawButtonLabel() and QButton::paintEvent().

Reimplemented from QButton.

voidQToolButton::drawButtonLabel(QPainter*p) [virtualprotected]

Draws the contents of the button (pixmap and optionally text).

See also: drawButton() and QButton::paintEvent().

Reimplemented from QButton.

voidQToolButton::enterEvent(QEvent*e) [virtualprotected]

Reimplemented to handle the automatic 3D effects in Windows style.

Reimplemented from QWidget.

QIconSetQToolButton::iconSet(boolon=FALSE)const

Returns a copy of the icon set in use. If no icon set has been set, iconSet() creates one from the pixmap().

If the button doesn't have a pixmap either, iconSet()'s return value is meaningless.

If on equals TRUE, the special icon set for the on-state of the button is returned.

See also: setIconSet() and QIconSet.

voidQToolButton::leaveEvent(QEvent*e) [virtualprotected]

Reimplemented to handle the automatic 3D effects in Windows style.

Reimplemented from QWidget.

voidQToolButton::setIconSet(constQIconSet&set, boolon=FALSE) [virtual]

Sets this tool button to display the icons in set. (setPixmap() is effectively a wrapper for this function.)

For toggle buttons it is possible to set an extra icon set with on equals TRUE, which will be used exclusively for the on-state.

QToolButton makes a copy of set, so you must delete set yourself.

See also: iconSet(), QIconSet, setToggleButton() and isOn().

voidQToolButton::setOn(boolenable) [virtualslot]

Sets this tool button to be on if enable is TRUE, and off it enable is FALSE.

This function has no effect on non-toggling buttons.

See also: isToggleButton() and toggle().

voidQToolButton::setTextLabel(constQString&newLabel, booltipToo=TRUE) [virtualslot]

Sets the label of this button to newLabel, and automatically sets it as tool tip too if tipToo is TRUE.

voidQToolButton::setToggleButton(boolenable) [virtualslot]

Makes the tool button a toggle button if enable is TRUE, or a normal tool button if enable is FALSE.

Toggle buttons have an on/off state similar to check boxes. A tool button is initially not a toggle button.

See also: setOn(), toggle(), toggleButton() and toggled().

voidQToolButton::setUsesBigPixmap(boolenable) [virtualslot]

Sets this button to use the big pixmaps provided by its QIconSet if enable is TRUE, and to use the small ones else.

QToolButton automatically connects this slot to the relevant signal in the QMainWindow in which it resides. You're strongly urged to use QMainWindow::setUsesBigPixmaps() instead.

Warning: If you set some buttons (in a QMainWindow) to have big and others small pixmaps, QMainWindow may have trouble getting the geometry correct.

voidQToolButton::setUsesTextLabel(boolenable) [virtualslot]

Sets this button to draw a text label below the icon if enable is TRUE, and to not draw it if enable is FALSE.

QToolButton automatically connects this slot to the relevant signal in the QMainWindow in which is resides.

QSizeQToolButton::sizeHint()const [virtual]

Returns a size suitable for this tool button. This depends on GUI style, usesBigPixmap(), textLabel() and usesTextLabel().

Reimplemented from QWidget.

QSizePolicyQToolButton::sizePolicy()const [virtual]

Specifies that this widget may grow.

Reimplemented from QWidget.

QStringQToolButton::textLabel()const

Returns the text label in use by this tool button, or 0.

See also: setTextLabel(), usesTextLabel(), setUsesTextLabel() and setText().

voidQToolButton::toggle() [slot]

Toggles the state of this tool button.

This function has no effect on non-toggling buttons.

See also: isToggleButton() and toggle().

boolQToolButton::uses3D()const [protected]

Returns TRUE if this button should be drawn using raised edges.

See also: drawButton().

boolQToolButton::usesBigPixmap()const

Returns TRUE if this tool button uses the big (32-pixel) pixmaps, and FALSE if it does not.

See also: setUsesBigPixmap(), setPixmap() and usesTextLabel.

boolQToolButton::usesTextLabel()const

Returns TRUE if this tool button puts a text label below the button pixmap, and FALSE if it does not.

See also: setUsesTextLabel(), setTextLabel() and usesBigPixmap().


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