The QButton class is the abstract base class of button widgets, and provides functionality common to buttons. More...
#include <qbutton.h>
Inherits QWidget.
Inherited by QCheckBox, QPushButton and QRadioButton.
The QButton class implements an abstract button, and lets subclasses specify how to reply to user actions and how to draw the button.
The QButton class has three signals. The pressed() signal is emitted when the left mouse button is pressed while the cursor is inside the button. After being pressed, the button will be down until the left mouse button is again released, which causes a released() signal. If the left mouse button is released when the cursor is inside the button, the clicked() signal will be emitted.
There are two types of buttons; standard buttons and toggle buttons. A standard button can either be pressed down or released. The QPushButton class is an example of a standard button. A toggle button has an additional flag that is toggled each time the button is clicked. The QRadioButton and QCheckBox classes are examples of toggle buttons.
The button label can be a text or a pixmap. It is up to widget implementation to display the text or the pixmap. All the button classess provided with Qt can show both texts and pixmaps.
Another convention regarding QButtons is auto-resizing. Enabling auto-resizing makes a button resize itself whenever the contents change.
See also: QButtonGroup.
Examples: tictac/tictac.cpp
Constructs a standard button with a parent widget and a name.
If parent is a QButtonGroup, this constructor calls QButtonGroup::insert().
Destroys the button and all its child widgets.
Returns TRUE if auto-resizing is enabled, or FALSE if auto-resizing is disabled.
Auto-resizing is disabled by default.
See also: setAutoResize().
[signal]
This signal is emitted when the button is activated (i.e. first pressed down and then released when the mouse cursor is inside the button).
See also: pressed(), released() and toggled().
[virtual protected]
Draws the button. The default implementation does nothing.
This virtual function is reimplemented by subclasses to draw real buttons.
Reimplemented in QPushButton, QRadioButton and QCheckBox.
[virtual protected]
Draws the button text or pixmap. The default implementation does nothing.
This virtual function is reimplemented by subclasses to draw real buttons.
Reimplemented in QPushButton, QRadioButton and QCheckBox.
[virtual protected]
Handles focus in events for the button.
See also: focusOutEvent().
Reimplemented from QWidget.
[virtual protected]
Handles focus out events for the button.
See also: focusInEvent().
Reimplemented from QWidget.
[virtual protected]
Returns TRUE if pos is inside the widget rectangle, or FALSE if it is outside.
This virtual function is reimplemented by subclasses.
Reimplemented in QRadioButton.
Returns TRUE if the button pressed down, or FALSE if it is standing up.
See also: setDown().
Examples: tictac/tictac.cpp
Returns TRUE if this toggle button is switched on, or FALSE if it is switched off.
See also: setOn() and toggleButton().
Returns TRUE if the button is a toggle button.
See also: setToggleButton().
[virtual protected]
Handles keyboard events for the button.
Space is the only key that has any effect; it emulates a mousePressEvent() followed by a mouseReleaseEvent().
Reimplemented from QWidget.
[virtual protected]
Handles mouse move events for the button.
See also: mousePressEvent() and mouseReleaseEvent().
Reimplemented from QWidget.
[virtual protected]
Handles mouse press events for the button.
See also: mouseReleaseEvent().
Reimplemented from QWidget.
[virtual protected]
Handles mouse release events for the button.
See also: mousePressEvent().
Reimplemented from QWidget.
[virtual protected]
Handles paint events for the button.
Opens the painter on the button and calls drawButton().
Reimplemented from QWidget.
Returns the button pixmap, or 0 if the button has no pixmap.
[signal]
This signal is emitted when the button is pressed down.
See also: released() and clicked().
[signal]
This signal is emitted when the button is released.
See also: pressed(), clicked() and toggled().
Turns on auto-repeat for the button if enable is TRUE, or turns it off if enable is FALSE.
When auto-repeat is enabled, the clicked() signal is emitted at regular intervals while the buttons is down.
setAutoRepeat() has no effect for toggle buttons.
See also: isDown(), autoRepeat() and clicked().
Enables auto-resizing if enable is TRUE, or disables it if enable is FALSE.
When auto-resizing is enabled, the button will resize itself whenever the contents change.
See also: autoResize() and adjustSize().
[protected]
Sets the state of the button to pressed down if enable is TRUE or to standing up if enable is FALSE.
If the button is a toggle button, it is not toggled. Call toggle() as well if you need to do that. The pressed() and released() signals are not emitted by this function.
This method is provided in case you need to override the mouse event handlers.
See also: isDown(), setOn(), toggle() and toggled().
[protected]
Switches a toggle button on if enable is TRUE or off if enable is FALSE. This function should be called only for toggle buttons.
See also: isOn() and toggleButton().
Sets the button pixmap to pixmap and redraws the contents.
If pixmap is monochrome (i.e. it is a QBitmap or its depth is 1) and it does not have a mask, this function sets the pixmap to be its own mask. The purpose is to draw transparent bitmaps, which is important for e.g. toggle buttons.
The button resizes itself if auto-resizing is enabled.
See also: pixmap(), setText(), setAutoResize() and QPixmap::mask().
Examples: widgets/widgets.cpp
Sets the button contents to text and redraws the contents.
The button resizes itself if auto-resizing is enabled.
See also: text(), setPixmap() and setAutoResize().
Examples: qmag/qmag.cpp widgets/widgets.cpp
[protected]
Makes the button a toggle button if enable is TRUE, or a normal button if enable is FALSE.
Note that this function is protected. It is called from subclasses to enable the toggle functionality. QCheckBox and QRadioButton are toggle buttons. QPushButton is initially not a toggle button, but QPushButton::setToggleButton() can be called to create toggle buttons.
See also: isToggleButton().
Returns the button text, or 0 if the button has no text.
See also: setText().
[signal]
This signal is emitted whenever a toggle button changes status. on is TRUE if the button is on, or FALSE if the button is off.
This may be the result of a user action, toggle() slot activation, or because setOn() was called.
See also: clicked().
This file is part of the Qt toolkit, copyright © 1995-97 Troll Tech, all rights reserved.
It was generated from the following files: