TQButton provides both push and toggle buttons. The TQRadioButton and TQCheckBox classes provide only toggle buttons; TQPushButton and TQToolButton provide both toggle and push buttons.
Any button can have either a text or pixmap label. setText() sets the button to be a text button and setPixmap() sets it to be a pixmap button. The text/pixmap is manipulated as necessary to create the "disabled" appearance when the button is disabled.
isDown() indicates whether the button is \fIpressed\fR down.
.TP
isOn() indicates whether the button is \fIon\fR. Only toggle buttons can be switched on and off (see below).
.TP
isEnabled() indicates whether the button can be pressed by the user.
.TP
setAutoRepeat() sets whether the button will auto-repeat if the user holds it down.
.TP
setToggleButton() sets whether the button is a toggle button or not.
.PP
The difference between isDown() and isOn() is as follows: When the user clicks a toggle button to toggle it on, the button is first \fIpressed\fR and then released into the \fIon\fR state. When the user clicks it again (to toggle it off), the button moves first to the \fIpressed\fR state, then to the \fIoff\fR state (isOn() and isDown() are both FALSE).
If the button is a text button with an ampersand (&) in its text, TQButton creates an automatic accelerator key. This code creates a push button labelled "Ro<u>c</u>k & Roll" (where the c is underlined). The button gets an automatic accelerator key, Alt+C:
In this example, when the user presses Alt+C the button will call animateClick().
.PP
You can also set a custom accelerator using the setAccel() function. This is useful mostly for pixmap buttons because they have no automatic accelerator.
To subclass TQButton, you must reimplement at least drawButton() (to draw the button's outline) and drawButtonLabel() (to draw its text or pixmap). It is generally advisable to reimplement sizeHint() as well, and sometimes hitButton() (to determine whether a button press is within the button).
To reduce flickering, TQButton::paintEvent() sets up a pixmap that the drawButton() function draws in. You should not reimplement paintEvent() for a subclass of TQButton unless you want to take over all drawing.
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), when the accelerator key is typed or when animateClick() is called. This signal is \fInot\fR emitted if you call setDown().
Handles paint events for buttons. Small and typically complex buttons are painted double-buffered to reduce flicker. The actually drawing is done in the virtual functions drawButton() and drawButtonLabel().
This signal is emitted whenever a toggle button changes state. \fIstate\fR is On if the button is on, NoChange if it is in the" no change" state or Off if the button is off.
.PP
This may be the result of a user action, toggle() slot activation, setState(), or because setOn() was called.
This property holds the accelerator associated with the button.
.PP
This property is 0 if there is no accelerator set. If you set this property to 0 then any current accelerator is removed.
.PP
Set this property's value with setAccel() and get this property's value with accel().
.SH "bool autoRepeat"
This property holds whether autoRepeat is enabled.
.PP
If autoRepeat is enabled then the clicked() signal is emitted at regular intervals if the button is down. This property has no effect on toggle buttons. autoRepeat is off by default.
.PP
Set this property's value with setAutoRepeat() and get this property's value with autoRepeat().
.SH "bool down"
This property holds whether the button is pressed.
.PP
If this property is TRUE, the button is pressed down. The signals pressed() and clicked() are not emitted if you set this property to TRUE. The default is FALSE.
.PP
Set this property's value with setDown() and get this property's value with isDown().
.SH "bool exclusiveToggle"
This property holds whether the button is an exclusive toggle.
If this property is TRUE and the button is in a TQButtonGroup, the button can only be toggled off by another one being toggled on. The default is FALSE.
If the pixmap is monochrome (i.e. it is a TQBitmap or its depth is 1) and it does not have a mask, this property will set the pixmap to be its own mask. The purpose of this is to draw transparent bitmaps which are important for toggle buttons, for example.
This property will return a TQString::null if the button has no text. If the text has an ampersand (&) in it, then an accelerator is automatically created for it using the character that follows the '&' as the accelerator key. Any previous accelerator will be overwritten, or cleared if no accelerator is defined by the text.