The push button, or command button, is perhaps the most commonly used widget in any graphical user interface. Push (click) a button to command the computer to perform some action, or to answer a question. Typical buttons are OK, Apply, Cancel, Close, Yes, No and Help.
.PP
A command button is rectangular and typically displays a text label describing its action. An underlined character in the label (signified by preceding it with an ampersand in the text) indicates an accelerator key, e.g.
In this example the accelerator is \fIAlt+D\fR, and the label text will be displayed as \fB<u>D</u>ownload\fR.
.PP
Push buttons can display a textual label or a pixmap, and optionally a small icon. These can be set using the constructors and changed later using setText(), setPixmap() and setIconSet(). If the button is disabled the appearance of the text or pixmap and iconset will be manipulated with respect to the GUI style to make the button look "disabled".
.PP
A push button emits the signal clicked() when it is activated by the mouse, the Spacebar or by a keyboard accelerator. Connect to this signal to perform the button's action. Push buttons also provide less commonly used signals, for example, pressed() and released().
.PP
Command buttons in dialogs are by default auto-default buttons, i.e. they become the default push button automatically when they receive the keyboard input focus. A default button is a push button that is activated when the user presses the Enter or Return key in a dialog. You can change this with setAutoDefault(). Note that auto-default buttons reserve a little extra space which is necessary to draw a default-button indicator. If you do not want this space around your buttons, call setAutoDefault(FALSE).
.PP
Being so central, the button widget has grown to accommodate a great many variations in the past decade. The Microsoft style guide now shows about ten different states of Windows push buttons and the text implies that there are dozens more when all the combinations of features are taken into consideration.
.PP
The most important modes or states are:
.TP
Available or not (grayed out, disabled).
.TP
Standard push button, toggling push button or menu button.
.TP
On or off (only for toggling push buttons).
.TP
Default or normal. The default button in a dialog can generally be "clicked" using the Enter or Return key.
As a general rule, use a push button when the application or dialog window performs an action when the user clicks on it (such as Apply, Cancel, Close and Help) \fIand\fR when the widget is supposed to have a wide, rectangular shape with a text label. Small, typically square buttons that change the state of the window rather than performing an action (such as the buttons in the top-right corner of the TQFileDialog) are not command buttons, but tool buttons. TQt provides a special class (TQToolButton) for these buttons.
If you need toggle behavior (see setToggleButton()) or a button that auto-repeats the activation signal when being pushed down like the arrows in a scroll bar (see setAutoRepeat()), a command button is probably not what you want. When in doubt, use a tool button.
.PP
A variation of a command button is a menu button. These provide not just one command, but several, since when they are clicked they pop up a menu of options. Use the method setPopup() to associate a popup menu with a push button.
In Qt, the TQButton abstract base class provides most of the modes and other API, and TQPushButton provides GUI logic. See TQButton for more information about the API.
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().
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.
In some GUI styles a default button is drawn with an extra frame around it, up to 3 pixels or more. TQt automatically keeps this space free around auto-default buttons, i.e. auto-default buttons may have a slightly larger size hint.
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 default"
This property holds whether the push button is the default button.
.PP
If this property is set to TRUE then the push button will be pressed if the user presses the Enter (or Return) key in a dialog.
.PP
Regardless of focus, if the user presses Enter: If there is a default button the default button is pressed; otherwise, if there are one or more autoDefault buttons the first autoDefault button that is next in the tab order is pressed. If there are no default or autoDefault buttons only pressing Space on a button with focus, mouse clicking, or using an accelerator will press a button.
.PP
In a dialog, only one push button at a time can be the default button. This button is then displayed with an additional frame (depending on the GUI style).
.PP
The default button behavior is provided only in dialogs. Buttons can always be clicked from the keyboard by pressing Enter (or Return) or the Spacebar when the button has focus.
.PP
This property's default is FALSE.
.PP
Set this property's value with setDefault() and get this property's value with isDefault().
.SH "bool flat"
This property holds whether the border is disabled.
.PP
This property's default is FALSE.
.PP
Set this property's value with setFlat() and get this property's value with isFlat().
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.