Classes - Annotated - Tree - Functions - Home - Structure

QToolButton Class Reference

The QToolButton class provides a quick-access button to specific commands or options, usually used inside a QToolBar. More...

#include <qtoolbutton.h>

Inherits QButton.

List of all member functions.

Public Members

Public Slots

Properties

Protected Members


Detailed Description

The QToolButton class provides a quick-access button to specific commands or options, usually used inside a QToolBar.

A tool button is a special button that provides quick-access to specific commands or options. As opposed to a normal command button, a tool button usually doesn't show a text label, but an icon. Its classic usage is to select tools, for example the "pen" tool in a drawing program. This would be implemented with a QToolButton as toggle button (see setToggleButton() ).

QToolButton supports auto-raising. In auto-raise mode, the button draws a 3D frame only when the mouse points at it. The feature is automatically turned on when a button is used inside a QToolBar. Change it with setAutoRaise().

A tool button's icon is set as QIconSet. This makes it possible to specify different pixmaps for the disabled and active state. The disabled pixmap is used when the button's functionality is not available. The active pixmap is displayed when the button is auto-raised because the user is pointing at it.

The button's look and dimension is adjustable with setUsesBigPixmap() and setUsesTextLabel(). When used inside a QToolBar, the button automatically adjusts to QMainWindow's settings (see QMainWindow::setUsesTextLabel() and QMainWindow::setUsesBigPixmaps()).

A tool button can offer additional choices in a popup menu. The feature is sometimes used with the "Back" button in a web browser. After pressing the button down for awhile, a menu pops up showing all possible pages to browse back. With QToolButton you can set a popup menu using setPopup(). The default delay is 600ms; you may adjust it with setPopupDelay().

See also QPushButton, QToolBar, QMainWindow and GUI Design Handbook: Push Button.


Member Function Documentation

QToolButton::QToolButton ( QWidget * parent, const char * name = 0 )

Constructs an empty tool button.

QToolButton::QToolButton ( const QIconSet & iconSet, const QString & textLabel, const QString & grouptext, QObject * receiver, const char * slot, QToolBar * parent, const char * name = 0 )

Constructs 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, it will be connected to slot in object receiver.

QToolButton::QToolButton ( ArrowType type, QWidget * parent, const char * name = 0 )

Constructs a tool button as arrow button. The ArrowType type defines the arrow direction. Possible values are LeftArrow, RightArrow, UpArrow and DownArrow.

An arrow button has auto-repeat turned on.

The parent and name arguments are sent to the QWidget constructor.

QToolButton::~QToolButton ()

Destroys the object and frees any allocated resources.

bool QToolButton::autoRaise () const

Returns TRUE if auto-raising is enabled or not; otherwise returns FALSE. See the "autoRaise" property for details.

QIconSet QToolButton::iconSet () const

Returns the icon set providing the icon shown on the button. See the "iconSet" property for details.

QIconSet QToolButton::iconSet ( bool on ) const

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

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

Since Qt 3.0, QIconSet contains both the On and Off icons.

For ease of porting, this function ignores the on parameter and returns the iconSet property. If you relied on the on parameter, you probably want to update your code to use the QIconSet On/Off mechanism.

QIconSet QToolButton::offIconSet () const

Returns the icon set that is used when the button is in an "off" state. See the "offIconSet" property for details.

QIconSet QToolButton::onIconSet () const

Returns the icon set that is used when the button is in an "on" state. See the "onIconSet" property for details.

QPopupMenu * QToolButton::popup () const

Returns the associated popup menu or 0 if no popup menu has been defined.

See also setPopup().

int QToolButton::popupDelay () const

Returns the time delay between pressing the button and the appearance of the associated popup menu in milliseconds. See the "popupDelay" property for details.

void QToolButton::setAutoRaise ( bool enable )

Sets whether auto-raising is enabled or not to enable. See the "autoRaise" property for details.

void QToolButton::setIconSet ( const QIconSet & ) [virtual]

Sets the icon set providing the icon shown on the button. See the "iconSet" property for details.

void QToolButton::setIconSet ( const QIconSet & set, bool on )

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

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

Since Qt 3.0, QIconSet contains both the On and Off icons.

For ease of porting, this function ignores the on parameter and sets the iconSet property. If you relied on the on parameter, you probably want to update your code to use the QIconSet On/Off mechanism.

See also iconSet and QIconSet::State.

void QToolButton::setOffIconSet ( const QIconSet & )

Sets the icon set that is used when the button is in an "off" state. See the "offIconSet" property for details.

void QToolButton::setOn ( bool enable ) [virtual slot]

Sets whether this tool button is on to enable. See the "on" property for details.

void QToolButton::setOnIconSet ( const QIconSet & )

Sets the icon set that is used when the button is in an "on" state. See the "onIconSet" property for details.

void QToolButton::setPopup ( QPopupMenu * popup )

Associates the popup menu popup with this tool button.

The popup will be shown each time the tool button has been pressed down for a certain amount of time. A typical application example is the "back" button in some web browsers's tool bars. If the user clicks it, the browser simply browses back to the previous page. If the user holds the button down for a while, the tool button shows a menu containing the current history list.

Ownership of the popup menu is not transferred.

See also popup().

void QToolButton::setPopupDelay ( int delay )

Sets the time delay between pressing the button and the appearance of the associated popup menu in milliseconds to delay. See the "popupDelay" property for details.

void QToolButton::setTextLabel ( const QString & newLabel, bool tipToo ) [virtual slot]

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

void QToolButton::setTextLabel ( const QString & ) [slot]

Sets the label of this button. See the "textLabel" property for details.

void QToolButton::setToggleButton ( bool enable ) [virtual slot]

Sets whether this tool button is a toggle button to enable. See the "toggleButton" property for details.

void QToolButton::setUsesBigPixmap ( bool enable ) [virtual slot]

Sets whether this toolbutton uses big pixmaps to enable. See the "usesBigPixmap" property for details.

void QToolButton::setUsesTextLabel ( bool enable ) [virtual slot]

Sets whether the toolbutton displays a text label below the button pixmap to enable. See the "usesTextLabel" property for details.

QString QToolButton::textLabel () const

Returns the label of this button. See the "textLabel" property for details.

void QToolButton::toggle () [slot]

Toggles the state of this tool button.

This function has no effect on non-toggling buttons.

See also toggleButton and toggled().

bool QToolButton::uses3D () const [protected]

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

See also drawButton().

bool QToolButton::usesBigPixmap () const

Returns TRUE if this toolbutton uses big pixmaps; otherwise returns FALSE. See the "usesBigPixmap" property for details.

bool QToolButton::usesTextLabel () const

Returns TRUE if the toolbutton displays a text label below the button pixmap; otherwise returns FALSE. See the "usesTextLabel" property for details.


Property Documentation

bool autoRaise

This property holds whether auto-raising is enabled or not.

Set this property's value with setAutoRaise() and get this property's value with autoRaise().

QIconSet iconSet

This property holds the icon set providing the icon shown on the button.

Set this property's value with setIconSet() and get this property's value with iconSet().

See also pixmap, toggleButton and on.

QIconSet offIconSet

This property holds the icon set that is used when the button is in an "off" state.

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

Since Qt 3.0, QIconSet contains both the On and Off icons. There is now an iconSet property that replaces both onIconSet and offIconSet.

For ease of porting, this property is a synonym for iconSet. You probably want to go over your application code and use the QIconSet On/Off mechanism.

Set this property's value with setOffIconSet() and get this property's value with offIconSet().

See also iconSet and QIconSet::State.

bool on

This property holds whether this tool button is on.

This property has no effect on non-toggling buttons.

Set this property's value with setOn().

See also toggleButton and toggle().

QIconSet onIconSet

This property holds the icon set that is used when the button is in an "on" state.

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

Since Qt 3.0, QIconSet contains both the On and Off icons. There is now an iconSet property that replaces both onIconSet and offIconSet.

For ease of porting, this property is a synonym for iconSet. You probably want to go over your application code and use the QIconSet On/Off mechanism.

Set this property's value with setOnIconSet() and get this property's value with onIconSet().

See also iconSet and QIconSet::State.

int popupDelay

This property holds the time delay between pressing the button and the appearance of the associated popup menu in milliseconds.

Usually this is around half a second. A value of 0 will add a special section to the toolbutton that can be used to open the popupmenu.

Set this property's value with setPopupDelay() and get this property's value with popupDelay().

See also setPopup().

QString textLabel

This property holds the label of this button.

Setting this property automatically sets it as tool tip, too.

Set this property's value with setTextLabel() and get this property's value with textLabel().

See also setTextLabel(, const, QString, &newLabel, bool, tipToo and ).

bool toggleButton

This property holds whether this tool button is a toggle button.

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

Set this property's value with setToggleButton().

See also on and toggle().

bool usesBigPixmap

This property holds whether this toolbutton uses big pixmaps.

QToolButton automatically connects this property 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 pixmaps and others to have small pixmaps, QMainWindow may have trouble getting the geometry correct.

Set this property's value with setUsesBigPixmap() and get this property's value with usesBigPixmap().

bool usesTextLabel

This property holds whether the toolbutton displays a text label below the button pixmap.

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

Set this property's value with setUsesTextLabel() and get this property's value with usesTextLabel().


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


This file is part of the Qt toolkit, copyright © 1995-2001 Trolltech, all rights reserved.


Copyright © 2001 TrolltechTrademarks
Qt version 3.0.0-beta1-beta1