1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
|
'\" t
.TH QPushButton 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA. All rights reserved. See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QPushButton \- Command button
.SH SYNOPSIS
\fC#include <ntqpushbutton.h>\fR
.PP
Inherits QButton.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQPushButton\fR ( TQWidget * parent, const char * name = 0 )"
.br
.ti -1c
.BI "\fBQPushButton\fR ( const TQString & text, TQWidget * parent, const char * name = 0 )"
.br
.ti -1c
.BI "\fBQPushButton\fR ( const QIconSet & icon, const TQString & text, TQWidget * parent, const char * name = 0 )"
.br
.ti -1c
.BI "\fB~QPushButton\fR ()"
.br
.ti -1c
.BI "void \fBsetToggleButton\fR ( bool )"
.br
.ti -1c
.BI "bool \fBautoDefault\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetAutoDefault\fR ( bool autoDef )"
.br
.ti -1c
.BI "bool \fBisDefault\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetDefault\fR ( bool def )"
.br
.ti -1c
.BI "virtual void setIsMenuButton ( bool enable ) \fI(obsolete)\fR"
.br
.ti -1c
.BI "bool isMenuButton () const \fI(obsolete)\fR"
.br
.ti -1c
.BI "void \fBsetPopup\fR ( QPopupMenu * popup )"
.br
.ti -1c
.BI "QPopupMenu * \fBpopup\fR () const"
.br
.ti -1c
.BI "void \fBsetIconSet\fR ( const QIconSet & )"
.br
.ti -1c
.BI "QIconSet * \fBiconSet\fR () const"
.br
.ti -1c
.BI "void \fBsetFlat\fR ( bool )"
.br
.ti -1c
.BI "bool \fBisFlat\fR () const"
.br
.in -1c
.SS "Public Slots"
.in +1c
.ti -1c
.BI "virtual void \fBsetOn\fR ( bool )"
.br
.in -1c
.SS "Important Inherited Members"
.in +1c
.ti -1c
.BI "TQString \fBtext\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetText\fR ( const TQString & )"
.br
.ti -1c
.BI "const QPixmap * \fBpixmap\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetPixmap\fR ( const QPixmap & )"
.br
.ti -1c
.BI "QKeySequence \fBaccel\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetAccel\fR ( const QKeySequence & )"
.br
.ti -1c
.BI "bool \fBisToggleButton\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetDown\fR ( bool )"
.br
.ti -1c
.BI "bool \fBisDown\fR () const"
.br
.ti -1c
.BI "bool \fBisOn\fR () const"
.br
.ti -1c
.BI "ToggleState \fBstate\fR () const"
.br
.ti -1c
.BI "bool \fBautoRepeat\fR () const"
.br
.ti -1c
.BI "virtual void \fBsetAutoRepeat\fR ( bool )"
.br
.ti -1c
.BI "bool \fBisExclusiveToggle\fR () const"
.br
.ti -1c
.BI "QButtonGroup * \fBgroup\fR () const"
.br
.ti -1c
.BI "void \fBtoggle\fR ()"
.br
.ti -1c
.BI "void \fBpressed\fR ()"
.br
.ti -1c
.BI "void \fBreleased\fR ()"
.br
.ti -1c
.BI "void \fBclicked\fR ()"
.br
.ti -1c
.BI "void \fBtoggled\fR ( bool on )"
.br
.ti -1c
.BI "void \fBstateChanged\fR ( int state )"
.br
.in -1c
.SS "Properties"
.in +1c
.ti -1c
.BI "bool \fBautoDefault\fR - whether the push button is the auto default button"
.br
.ti -1c
.BI "bool \fBautoMask\fR - whether the button is automatically masked \fI(read " "only" ")\fR"
.br
.ti -1c
.BI "bool \fBdefault\fR - whether the push button is the default button"
.br
.ti -1c
.BI "bool \fBflat\fR - whether the border is disabled"
.br
.ti -1c
.BI "QIconSet \fBiconSet\fR - the icon set on the push button"
.br
.ti -1c
.BI "bool menuButton - whether the push button has a menu button on it \fI(read " "only" ")\fR \fI(obsolete)\fR"
.br
.ti -1c
.BI "bool \fBon\fR - whether the push button is toggled"
.br
.ti -1c
.BI "bool \fBtoggleButton\fR - whether the button is a toggle button"
.br
.in -1c
.SH DESCRIPTION
The QPushButton widget provides a command button.
.PP
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.
.PP
.nf
.br
QPushButton *pb = new QPushButton( "&Download", this );
.br
.fi
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.
.TP
Auto-repeat or not.
.TP
Pressed down or not.
.PP
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 QFileDialog) are not command buttons, but tool buttons. TQt provides a special class (QToolButton) for these buttons.
.PP
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.
.PP
Other classes of buttons are option buttons (see QRadioButton) and check boxes (see QCheckBox).
.PP
.ce 1
.B "[Image Omitted]"
.PP
.ce 1
.B "[Image Omitted]"
.PP
In Qt, the QButton abstract base class provides most of the modes and other API, and QPushButton provides GUI logic. See QButton for more information about the API.
.PP
See also QToolButton, QRadioButton, QCheckBox, GUI Design Handbook: Push Button, and Basic Widgets.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QPushButton::QPushButton ( TQWidget * parent, const char * name = 0 )"
Constructs a push button with no text.
.PP
The \fIparent\fR and \fIname\fR arguments are sent on to the TQWidget constructor.
.SH "QPushButton::QPushButton ( const TQString & text, TQWidget * parent, const char * name = 0 )"
Constructs a push button called \fIname\fR with the parent \fIparent\fR and the text \fItext\fR.
.SH "QPushButton::QPushButton ( const QIconSet & icon, const TQString & text, TQWidget * parent, const char * name = 0 )"
Constructs a push button with an \fIicon\fR and a \fItext\fR.
.PP
Note that you can also pass a QPixmap object as an icon (thanks to the implicit type conversion provided by C++).
.PP
The \fIparent\fR and \fIname\fR arguments are sent to the TQWidget constructor.
.SH "QPushButton::~QPushButton ()"
Destroys the push button.
.SH "QKeySequence QButton::accel () const"
Returns the accelerator associated with the button. See the "accel" property for details.
.SH "bool QPushButton::autoDefault () const"
Returns TRUE if the push button is the auto default button; otherwise returns FALSE. See the "autoDefault" property for details.
.SH "bool QButton::autoRepeat () const"
Returns TRUE if autoRepeat is enabled; otherwise returns FALSE. See the "autoRepeat" property for details.
.SH "void QButton::clicked ()\fC [signal]\fR"
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().
.PP
The QButtonGroup::clicked() signal does the same job, if you want to connect several buttons to the same slot.
.PP
\fBWarning:\fR Don't launch a model dialog in response to this signal for a button that has autoRepeat turned on.
.PP
See also pressed(), released(), toggled(), autoRepeat, and down.
.PP
Examples:
.)l chart/setdataform.cpp, listbox/listbox.cpp, network/clientserver/client/client.cpp, progressbar/progressbar.cpp, richtext/richtext.cpp, t2/main.cpp, and t4/main.cpp.
.SH "QButtonGroup * QButton::group () const"
Returns the group that this button belongs to.
.PP
If the button is not a member of any QButtonGroup, this function returns 0.
.PP
See also QButtonGroup.
.SH "QIconSet * QPushButton::iconSet () const"
Returns the icon set on the push button. See the "iconSet" property for details.
.SH "bool QPushButton::isDefault () const"
Returns TRUE if the push button is the default button; otherwise returns FALSE. See the "default" property for details.
.SH "bool QButton::isDown () const"
Returns TRUE if the button is pressed; otherwise returns FALSE. See the "down" property for details.
.SH "bool QButton::isExclusiveToggle () const"
Returns TRUE if the button is an exclusive toggle; otherwise returns FALSE. See the "exclusiveToggle" property for details.
.SH "bool QPushButton::isFlat () const"
Returns TRUE if the border is disabled; otherwise returns FALSE. See the "flat" property for details.
.SH "bool QPushButton::isMenuButton () const"
Returns TRUE if the push button has a menu button on it; otherwise returns FALSE. See the "menuButton" property for details.
.SH "bool QButton::isOn () const"
Returns TRUE if the button is toggled; otherwise returns FALSE. See the "on" property for details.
.SH "bool QButton::isToggleButton () const"
Returns TRUE if the button is a toggle button; otherwise returns FALSE. See the "toggleButton" property for details.
.SH "const QPixmap * QButton::pixmap () const"
Returns the pixmap shown on the button. See the "pixmap" property for details.
.SH "QPopupMenu * QPushButton::popup () const"
Returns the button's associated popup menu or 0 if no popup menu has been set.
.PP
See also setPopup().
.SH "void QButton::pressed ()\fC [signal]\fR"
This signal is emitted when the button is pressed down.
.PP
See also released() and clicked().
.PP
Examples:
.)l network/httpd/httpd.cpp and popup/popup.cpp.
.SH "void QButton::released ()\fC [signal]\fR"
This signal is emitted when the button is released.
.PP
See also pressed(), clicked(), and toggled().
.SH "void QButton::setAccel ( const QKeySequence & )\fC [virtual]\fR"
Sets the accelerator associated with the button. See the "accel" property for details.
.SH "void QPushButton::setAutoDefault ( bool autoDef )\fC [virtual]\fR"
Sets whether the push button is the auto default button to \fIautoDef\fR. See the "autoDefault" property for details.
.SH "void QButton::setAutoRepeat ( bool )\fC [virtual]\fR"
Sets whether autoRepeat is enabled. See the "autoRepeat" property for details.
.SH "void QPushButton::setDefault ( bool def )\fC [virtual]\fR"
Sets whether the push button is the default button to \fIdef\fR. See the "default" property for details.
.SH "void QButton::setDown ( bool )\fC [virtual]\fR"
Sets whether the button is pressed. See the "down" property for details.
.SH "void QPushButton::setFlat ( bool )"
Sets whether the border is disabled. See the "flat" property for details.
.SH "void QPushButton::setIconSet ( const QIconSet & )"
Sets the icon set on the push button. See the "iconSet" property for details.
.SH "void QPushButton::setIsMenuButton ( bool enable )\fC [virtual]\fR"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.SH "void QPushButton::setOn ( bool )\fC [virtual slot]\fR"
Sets whether the push button is toggled. See the "on" property for details.
.SH "void QButton::setPixmap ( const QPixmap & )\fC [virtual]\fR"
Sets the pixmap shown on the button. See the "pixmap" property for details.
.SH "void QPushButton::setPopup ( QPopupMenu * popup )"
Associates the popup menu \fIpopup\fR with this push button. This turns the button into a menu button.
.PP
Ownership of the popup menu is \fInot\fR transferred to the push button.
.PP
See also popup().
.PP
Examples:
.)l buttongroups/buttongroups.cpp and qdir/qdir.cpp.
.SH "void QButton::setText ( const TQString & )\fC [virtual]\fR"
Sets the text shown on the button. See the "text" property for details.
.SH "void QPushButton::setToggleButton ( bool )"
Sets whether the button is a toggle button. See the "toggleButton" property for details.
.SH "ToggleState QButton::state () const"
Returns the state of the toggle button. See the "toggleState" property for details.
.SH "void QButton::stateChanged ( int state )\fC [signal]\fR"
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.
.PP
See also clicked() and QButton::ToggleState.
.SH "TQString QButton::text () const"
Returns the text shown on the button. See the "text" property for details.
.SH "void QButton::toggle ()\fC [slot]\fR"
Toggles the state of a toggle button.
.PP
See also on, on, toggled(), and toggleButton.
.SH "void QButton::toggled ( bool on )\fC [signal]\fR"
This signal is emitted whenever a toggle button changes status. \fIon\fR is TRUE if the button is on, or FALSE if the button is off.
.PP
This may be the result of a user action, toggle() slot activation, or because setOn() was called.
.PP
See also clicked().
.PP
Example: listbox/listbox.cpp.
.SS "Property Documentation"
.SH "QKeySequence accel"
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 autoDefault"
This property holds whether the push button is the auto default button.
.PP
If this property is set to TRUE then the push button is the auto default button in a dialog.
.PP
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.
.PP
This property's default is TRUE for buttons that have a QDialog parent; otherwise it defaults to FALSE.
.PP
See the default property for details of how default and auto-default interact.
.PP
Set this property's value with setAutoDefault() and get this property's value with autoDefault().
.SH "bool autoMask"
This property holds whether the button is automatically masked.
.PP
See also TQWidget::autoMask.
.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 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().
.SH "QIconSet iconSet"
This property holds the icon set on the push button.
.PP
This property will return 0 if the push button has no iconset.
.PP
Set this property's value with setIconSet() and get this property's value with iconSet().
.SH "bool menuButton"
This property holds whether the push button has a menu button on it.
.PP
\fBThis property is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.PP
If this property is set to TRUE, then a down arrow is drawn on the push button to indicate that a menu will pop up if the user clicks on the arrow.
.PP
Get this property's value with isMenuButton().
.SH "bool on"
This property holds whether the push button is toggled.
.PP
This property should only be set for toggle push buttons. The default value is FALSE.
.PP
See also on, toggle(), toggled(), and toggleButton.
.PP
Set this property's value with setOn().
.SH "QPixmap pixmap"
This property holds the pixmap shown on the button.
.PP
If the pixmap is monochrome (i.e. it is a QBitmap 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.
.PP
pixmap() returns 0 if no pixmap was set.
.PP
Set this property's value with setPixmap() and get this property's value with pixmap().
.SH "TQString text"
This property holds the text shown on the button.
.PP
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.
.PP
There is no default text.
.PP
Set this property's value with setText() and get this property's value with text().
.SH "bool toggleButton"
This property holds whether the button is a toggle button.
.PP
Toggle buttons have an on/off state similar to check boxes. A push button is initially not a toggle button.
.PP
See also on, toggle(), toggleButton, and toggled().
.PP
Set this property's value with setToggleButton().
.SH "SEE ALSO"
.BR http://doc.trolltech.com/ntqpushbutton.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech.
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (tqpushbutton.3qt) and the Qt
version (3.3.8).
|