diff options
Diffstat (limited to 'doc/man/man3/tqbutton.3qt')
-rw-r--r-- | doc/man/man3/tqbutton.3qt | 490 |
1 files changed, 490 insertions, 0 deletions
diff --git a/doc/man/man3/tqbutton.3qt b/doc/man/man3/tqbutton.3qt new file mode 100644 index 000000000..2677a0000 --- /dev/null +++ b/doc/man/man3/tqbutton.3qt @@ -0,0 +1,490 @@ +'\" t +.TH QButton 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 +QButton \- The abstract base class of button widgets, providing functionality common to buttons +.SH SYNOPSIS +\fC#include <ntqbutton.h>\fR +.PP +Inherits QWidget. +.PP +Inherited by QCheckBox, QPushButton, QRadioButton, and QToolButton. +.PP +.SS "Public Members" +.in +1c +.ti -1c +.BI "\fBQButton\fR ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )" +.br +.ti -1c +.BI "\fB~QButton\fR ()" +.br +.ti -1c +.BI "QString \fBtext\fR () const" +.br +.ti -1c +.BI "virtual void \fBsetText\fR ( const QString & )" +.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 "enum \fBToggleType\fR { SingleShot, Toggle, Tristate }" +.br +.ti -1c +.BI "ToggleType \fBtoggleType\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 "enum \fBToggleState\fR { Off, NoChange, On }" +.br +.ti -1c +.BI "ToggleState \fBstate\fR () const" +.br +.ti -1c +.BI "bool autoResize () const \fI(obsolete)\fR" +.br +.ti -1c +.BI "void setAutoResize ( bool ) \fI(obsolete)\fR" +.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 +.in -1c +.SS "Public Slots" +.in +1c +.ti -1c +.BI "void \fBanimateClick\fR ()" +.br +.ti -1c +.BI "void \fBtoggle\fR ()" +.br +.in -1c +.SS "Signals" +.in +1c +.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 "QKeySequence \fBaccel\fR - the accelerator associated with the button" +.br +.ti -1c +.BI "bool \fBautoRepeat\fR - whether autoRepeat is enabled" +.br +.ti -1c +.BI "bool autoResize - whether autoResize is enabled \fI(obsolete)\fR" +.br +.ti -1c +.BI "bool \fBdown\fR - whether the button is pressed" +.br +.ti -1c +.BI "bool \fBexclusiveToggle\fR - whether the button is an exclusive toggle \fI(read " "only" ")\fR" +.br +.ti -1c +.BI "bool \fBon\fR - whether the button is toggled \fI(read " "only" ")\fR" +.br +.ti -1c +.BI "QPixmap \fBpixmap\fR - the pixmap shown on the button" +.br +.ti -1c +.BI "QString \fBtext\fR - the text shown on the button" +.br +.ti -1c +.BI "bool \fBtoggleButton\fR - whether the button is a toggle button \fI(read " "only" ")\fR" +.br +.ti -1c +.BI "ToggleState \fBtoggleState\fR - the state of the toggle button \fI(read " "only" ")\fR" +.br +.ti -1c +.BI "ToggleType \fBtoggleType\fR - the type of toggle on the button \fI(read " "only" ")\fR" +.br +.in -1c +.SS "Protected Members" +.in +1c +.ti -1c +.BI "void \fBsetToggleButton\fR ( bool b )" +.br +.ti -1c +.BI "virtual void \fBsetToggleType\fR ( ToggleType type )" +.br +.ti -1c +.BI "void \fBsetOn\fR ( bool on )" +.br +.ti -1c +.BI "virtual void \fBsetState\fR ( ToggleState s )" +.br +.ti -1c +.BI "virtual bool \fBhitButton\fR ( const QPoint & pos ) const" +.br +.ti -1c +.BI "virtual void \fBdrawButton\fR ( QPainter * )" +.br +.ti -1c +.BI "virtual void \fBdrawButtonLabel\fR ( QPainter * )" +.br +.ti -1c +.BI "virtual void \fBpaintEvent\fR ( QPaintEvent * )" +.br +.in -1c +.SH DESCRIPTION +The QButton class is the abstract base class of button widgets, providing functionality common to buttons. +.PP +\fBIf you want to create a button use QPushButton.\fR +.PP +The QButton class implements an \fIabstract\fR button, and lets subclasses specify how to reply to user actions and how to draw the button. +.PP +QButton provides both push and toggle buttons. The QRadioButton and QCheckBox classes provide only toggle buttons; QPushButton and QToolButton provide both toggle and push buttons. +.PP +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. +.PP +QButton provides most of the states used for buttons: +.TP +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). +.PP +Default buttons (as used in many dialogs) are provided by QPushButton::setDefault() and QPushButton::setAutoDefault(). +.PP +QButton provides five signals: <ol type=1> +.TP +pressed() is emitted when the button is pressed. E.g. with the mouse or when animateClick() is called. +.TP +released() is emitted when the button is released. E.g. when the mouse is released or the cursor is moved outside the widget. +.TP +clicked() is emitted when the button is first pressed and then released when the accelerator key is typed, or when animateClick() is called. +.TP +toggled(bool) is emitted when the state of a toggle button changes. +.TP +stateChanged(int) is emitted when the state of a tristate toggle button changes. +.PP +If the button is a text button with an ampersand (&) in its text, QButton 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: +.PP +.nf +.br + QPushButton *p = new QPushButton( "Ro&ck && Roll", this ); +.br +.fi +.PP +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. +.PP +.nf +.br + p->setPixmap( QPixmap("print.png") ); +.br + p->setAccel( ALT+Key_F7 ); +.br +.fi +.PP +All of the buttons provided by Qt (QPushButton, QToolButton, QCheckBox and QRadioButton) can display both text and pixmaps. +.PP +To subclass QButton, 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). +.PP +To reduce flickering, QButton::paintEvent() sets up a pixmap that the drawButton() function draws in. You should not reimplement paintEvent() for a subclass of QButton unless you want to take over all drawing. +.PP +See also QButtonGroup and Abstract Widget Classes. +.SS "Member Type Documentation" +.SH "QButton::ToggleState" +This enum defines the state of a toggle button. +.TP +\fCQButton::Off\fR - the button is in the "off" state +.TP +\fCQButton::NoChange\fR - the button is in the default/unchanged state +.TP +\fCQButton::On\fR - the button is in the "on" state +.SH "QButton::ToggleType" +This enum type defines what a button can do in response to a mouse/keyboard press: +.TP +\fCQButton::SingleShot\fR - pressing the button causes an action, then the button returns to the unpressed state. +.TP +\fCQButton::Toggle\fR - pressing the button toggles it between an On and an Off state. +.TP +\fCQButton::Tristate\fR - pressing the button cycles between the three states On, Off and NoChange +.SH MEMBER FUNCTION DOCUMENTATION +.SH "QButton::QButton ( QWidget * parent = 0, const char * name = 0, WFlags f = 0 )" +Constructs a standard button called \fIname\fR with parent \fIparent\fR, using the widget flags \fIf\fR. +.PP +If \fIparent\fR is a QButtonGroup, this constructor calls QButtonGroup::insert(). +.SH "QButton::~QButton ()" +Destroys the button. +.SH "QKeySequence QButton::accel () const" +Returns the accelerator associated with the button. See the "accel" property for details. +.SH "void QButton::animateClick ()\fC [slot]\fR" +Performs an animated click: the button is pressed and released a short while later. +.PP +The pressed(), released(), clicked(), toggled(), and stateChanged() signals are emitted as appropriate. +.PP +This function does nothing if the button is disabled. +.PP +See also accel. +.SH "bool QButton::autoRepeat () const" +Returns TRUE if autoRepeat is enabled; otherwise returns FALSE. See the "autoRepeat" property for details. +.SH "bool QButton::autoResize () const" +Returns TRUE if autoResize is enabled; otherwise returns FALSE. See the "autoResize" 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 "void QButton::drawButton ( QPainter * )\fC [virtual protected]\fR" +Draws the button. The default implementation does nothing. +.PP +This virtual function is reimplemented by subclasses to draw real buttons. At some point, these reimplementations should call drawButtonLabel(). +.PP +See also drawButtonLabel() and paintEvent(). +.SH "void QButton::drawButtonLabel ( QPainter * )\fC [virtual protected]\fR" +Draws the button text or pixmap. +.PP +This virtual function is reimplemented by subclasses to draw real buttons. It is invoked by drawButton(). +.PP +See also drawButton() and paintEvent(). +.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 "bool QButton::hitButton ( const QPoint & pos ) const\fC [virtual protected]\fR" +Returns TRUE if \fIpos\fR is inside the clickable button rectangle; otherwise returns FALSE. +.PP +By default, the clickable area is the entire widget. Subclasses may reimplement it, though. +.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 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 "void QButton::paintEvent ( QPaintEvent * )\fC [virtual protected]\fR" +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(). +.PP +See also drawButton() and drawButtonLabel(). +.PP +Reimplemented from QWidget. +.SH "const QPixmap * QButton::pixmap () const" +Returns the pixmap shown on the button. See the "pixmap" property for details. +.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 QButton::setAutoRepeat ( bool )\fC [virtual]\fR" +Sets whether autoRepeat is enabled. See the "autoRepeat" property for details. +.SH "void QButton::setAutoResize ( bool )" +Sets whether autoResize is enabled. See the "autoResize" 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 QButton::setOn ( bool on )\fC [protected]\fR" +Sets the state of this button to On if \fIon\fR is TRUE; otherwise to Off. +.PP +See also toggleState. +.SH "void QButton::setPixmap ( const QPixmap & )\fC [virtual]\fR" +Sets the pixmap shown on the button. See the "pixmap" property for details. +.SH "void QButton::setState ( ToggleState s )\fC [virtual protected]\fR" +Sets the toggle state of the button to \fIs\fR. \fIs\fR can be Off, NoChange or On. +.SH "void QButton::setText ( const QString & )\fC [virtual]\fR" +Sets the text shown on the button. See the "text" property for details. +.SH "void QButton::setToggleButton ( bool b )\fC [protected]\fR" +If \fIb\fR is TRUE, this button becomes a toggle button; if \fIb\fR is FALSE, this button becomes a command button. +.PP +See also toggleButton. +.SH "void QButton::setToggleType ( ToggleType type )\fC [virtual protected]\fR" +Sets the toggle type of the button to \fItype\fR. +.PP +\fItype\fR can be set to SingleShot, Toggle and Tristate. +.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 "QString 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, setOn(), toggled(), and toggleButton. +.SH "ToggleType QButton::toggleType () const" +Returns the type of toggle on the button. See the "toggleType" property for details. +.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 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 autoResize" +This property holds whether autoResize is enabled. +.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 autoResize is enabled then the button will resize itself whenever the contents are changed. +.PP +Set this property's value with setAutoResize() and get this property's value with autoResize(). +.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. +.PP +If this property is TRUE and the button is in a QButtonGroup, the button can only be toggled off by another one being toggled on. The default is FALSE. +.PP +Get this property's value with isExclusiveToggle(). +.SH "bool on" +This property holds whether the button is toggled. +.PP +This property should only be set for toggle buttons. +.PP +Get this property's value with isOn(). +.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 "QString text" +This property holds the text shown on the button. +.PP +This property will return a QString::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 +The default value is FALSE. +.PP +Get this property's value with isToggleButton(). +.SH "ToggleState toggleState" +This property holds the state of the toggle button. +.PP +If this property is changed then it does not cause the button to be repainted. +.PP +Get this property's value with state(). +.SH "ToggleType toggleType" +This property holds the type of toggle on the button. +.PP +The default toggle type is SingleShot. +.PP +See also QButton::ToggleType. +.PP +Get this property's value with toggleType(). + +.SH "SEE ALSO" +.BR http://doc.trolltech.com/ntqbutton.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 Qt documentation is provided in HTML format; it is +located at $QTDIR/doc/html and can be read using Qt 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 (tqbutton.3qt) and the Qt +version (3.3.8). |