?? qpushbutton.3qt
字號:
'\" t.TH QPushButton 3qt "24 January 2005" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2001 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQPushButton \- Command button.br.PP\fC#include <qpushbutton.h>\fR.PPInherits QButton..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQPushButton\fR ( QWidget * " "parent" ", const char * " "name" "=0 ) ".br.ti -1c.BI "\fBQPushButton\fR ( const QString & " "text" ", QWidget * " "parent" ", const char * " "name" "=0 ) ".br.ti -1c.BI "\fBQPushButton\fR ( const QIconSet & " "icon" ", const QString & " "text" ", QWidget * " "parent" ", const char * " "name" "=0 ) ".br.ti -1c.BI "\fB~QPushButton\fR () ".br.ti -1c.BI "virtual 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 ) \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.ti -1c.BI "void \fBtoggle\fR () ".br.in -1c.SS "Important Inherited Members".in +1c.ti -1c.BI "QString \fBtext\fR () const".br.ti -1c.BI "virtual void \fBsetText\fR ( const QString & text ) ".br.ti -1c.BI "QString \fBtext\fR () const".br.ti -1c.BI "const QPixmap* \fBpixmap\fR () const".br.ti -1c.BI "virtual void \fBsetPixmap\fR ( const QPixmap & pixmap ) ".br.ti -1c.BI "int \fBaccel\fR () const".br.ti -1c.BI "virtual void \fBsetAccel\fR ( int key ) ".br.ti -1c.BI "bool \fBisToggleButton\fR () const".br.ti -1c.BI "virtual void \fBsetDown\fR ( bool enable ) ".br.ti -1c.BI "bool \fBisDown\fR () const".br.ti -1c.BI "bool \fBisOn\fR () const".br.ti -1c.BI "bool \fBautoRepeat\fR () const".br.ti -1c.BI "bool \fBisExclusiveToggle\fR () const".br.ti -1c.BI "QButtonGroup* \fBgroup\fR () const".br.ti -1c.BI "virtual void \fBsetAutoRepeat\fR ( bool enable ) ".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".nf.TSl l l l l- - - - -l l l l l.Type Name READ WRITE Optionsbool autoDefault autoDefault setAutoDefaultbool default isDefault setDefaultbool menuButton isMenuButtonQIconSet iconSet iconSet setIconSetbool flat isFlat setFlat.TE.fi.SH DESCRIPTIONThe QPushButton widget provides a command button..PPThe push button, also referred to as command button, is perhaps the most central widget in any graphical user interface: Push it to command the computer to perform some action. Typical actions are Ok, Apply, Cancel, Close or Help..PPA command button is rectangular (ca. 80x22 pixel) and typically displays a text label describing its action. An underscored character in the label, marked with an ampersand in the text, signals an accelerator key..PPThis code creates a push button labelled "Rock & Roll". Due to the first ampersand, the c displays underscored and the button gets the automatic accelerator key, Alt-C:.PP.nf.br QPushButton *p = new QPushButton( "Ro&ck && Roll", this );.fi.PPThe text can be changed anytime later with setText(). You can also define a pixmap with setPixmap(). The text/pixmap is manipulated as necessary to create "disabled" appearance according to the respective GUI style when the button is disabled. A command button can, in addition to the text or pixmap label, also display a little icon. Use the extended constructor or setIconSet() to define this icon..PPA push button emits the signal clicked() when it is activated, either with the mouse, the spacebar or a keyboard accelerator. Connect to this signal to perform the button's action. Other signals of less importance are pressed() when the button is pressed down and released() when it is released, respectively..PPCommand 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 command button that is activated when the users hits the Enter or Return key in a dialog. Adjust this behaviour with setAutoDefault(). Note that auto-default buttons reserve a little extra space necessary to draw a default-button indicator. If you do not want this space around your buttons, call setAutoDefault( FALSE )..PPBeing so central, the widget has grown to accomodate a great many variations in the past decade, and by now the Microsoft style guide 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..PPThe most important modes or states are, sorted roughly by importance: .TPAvailable or not ("grayed out", disabled)..TPStandard push button, toggling push button or menu button..TPOn or off (only for toggling push buttons)..TPDefault or normal. The default button in a dialog can generally be "clicked" using the Enter or Return key..TPAuto-repeat or not..TPPressed down or not..PPAs a general rule, use a push button when the application or dialog window performs an action when the user clicks on it (like Apply, Cancel, Close, 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 (like for example the buttons in the top/right corner of the QFileDialog), are not command buttons, but tool buttons. Qt provides a special class QToolButton for these..PPAlso, if you need toggle behaviour (see setToggleButton()) or a button that auto-repeats the activation signal when being pushed down like the arrows in a scrollbar (see setAutoRepeat()), a command button is probably not what you want. In case of doubt, go with a tool button..PPA variation of a command button is a menu button. It provides not just one command, but several. Use the method setPopup() to associate a popup menu with a push button..PPOther 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]".PPIn Qt, the QButton class provides most of the modes and other API, and QPushButton provides GUI logic. See QButton for more information about the API..PPSee also QToolButton, QRadioButton, QCheckBox and GUI Design Handbook: Push Button.PPExamples:.(lscrollview/scrollview.cpp drawdemo/drawdemo.cpp i18n/main.cpp layout/layout.cpp customlayout/main.cpp qmag/qmag.cpp xform/xform.cpp popup/popup.cpp rot13/rot13.cpp.)l.SH MEMBER FUNCTION DOCUMENTATION.SH "QPushButton::QPushButton ( QWidget * parent, const char * name=0 )"Constructs a push button with no text..PPThe \fIparent\fR and \fIname\fR arguments are sent to the QWidget constructor..SH "QPushButton::QPushButton ( const QIconSet & icon, const QString & text, QWidget * parent, const char * name=0 )"Constructs a push button with an \fIicon\fR and a \fItext.\fR.PPNote that you can also pass a QPixmap object as icon (thanks to C++' implicit type conversion)..PPThe \fIparent\fR and \fIname\fR arguments are sent to the QWidget constructor..SH "QPushButton::QPushButton ( const QString & text, QWidget * parent, const char * name=0 )"Constructs a push button with a text..PPThe \fIparent\fR and \fIname\fR arguments are sent to the QWidget constructor..SH "QPushButton::~QPushButton ()"Destructs the push button..SH "bool QPushButton::autoDefault () const"Returns TRUE if the button is an auto-default button..PPSee also setAutoDefault()..SH "void QPushButton::drawButton ( QPainter * paint ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QButton..SH "void QPushButton::drawButtonLabel ( QPainter * paint ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QButton..SH "void QPushButton::focusInEvent ( QFocusEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QPushButton::focusOutEvent ( QFocusEvent * e ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "QIconSet* QPushButton::iconSet () const"Returns the button's icon or 0 if no icon has been defined..PPSee also setIconSet()..SH "bool QPushButton::isDefault () const"Returns TRUE if the button is currently default..PPSee also setDefault()..SH "bool QPushButton::isFlat () const"Returns whether the border is disabled..PPSee also setFlat()..SH "bool QPushButton::isMenuButton () const"\fBThis function is obsolete.\fR It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code..PPReturns TRUE if this button indicates to the user that pressing it will pop up a menu, and FALSE otherwise. The default is FALSE..PPSee also setIsMenuButton()..SH "void QPushButton::move ( const QPoint & p )"Reimplemented for internal reasons; the API is not affected..SH "void QPushButton::move ( int x, int y )"Reimplemented for internal reasons; the API is not affected..PPExamples:.(ldrawdemo/drawdemo.cpp.)l.SH "QPopupMenu* QPushButton::popup () const"Returns the associated popup menu or 0 if no popup menu has been defined..PPSee also setPopup()..SH "void QPushButton::resize ( const QSize & s )"Reimplemented for internal reasons; the API is not affected..PPExamples:.(ldrawdemo/drawdemo.cpp.)l.SH "void QPushButton::resize ( int w, int h )"Reimplemented for internal reasons; the API is not affected..SH "void QPushButton::resizeEvent ( QResizeEvent * ) \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QPushButton::setAutoDefault ( bool enable ) \fC[virtual]\fR"Sets the push buttons to an auto-default button if \fIenable\fR is TRUE, or to a normal button if \fIenable\fR is FALSE..PPAn auto-default button becomes automatically the default push button in a dialog when it receives the keyboard input focus..PPIn some GUI styles, a default button is drawn with an extra frame around it, up to 3 pixels or more. Qt automatically keeps this space free around auto-default buttons, i.e. auto-default buttons may have a slightly larger size hint..PPSee also autoDefault() and setDefault()..SH "void QPushButton::setDefault ( bool enable ) \fC[virtual]\fR"Sets this button to be the current default button of a dialog if \fIenable\fR is TRUE, or to be a normal button if \fIenable\fR is FALSE..PPThe current default button gets clicked when the user presses the" Enter" key, independently of which widget in the dialog currently has the keyboard input focus. Only one push button can at any time be the default button. This button is then displayed with an additional frame ( depending on the GUI style )..PPThe default button behaviour is only provided in dialogs. Buttons can always be clicked from the keyboard by pressing return or the spacebar when the button has focus..PPSee also isDefault(), setAutoDefault() and QDialog..SH "void QPushButton::setFlat ( bool f )"Disable the border..PPSee also flat()..SH "void QPushButton::setGeometry ( const QRect & r ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..SH "void QPushButton::setGeometry ( int x, int y, int w, int h ) \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPExamples:.(lqmag/qmag.cpp popup/popup.cpp.)l.SH "void QPushButton::setIconSet ( const QIconSet & icon )"Sets the button to display the icon \fIicon\fR in addition to its text or pixmap.PPSee also iconSet()..SH "void QPushButton::setIsMenuButton ( bool enable ) \fC[virtual]\fR"\fBThis function is obsolete.\fR It is provided to keep old source working, and will probably be removed in a future version of Qt. We strongly advise against using it in new code..PPTells this button to draw a menu indication triangle if \fIenable\fR is TRUE, and to not draw one if \fIenable\fR is FALSE (the default)..PPsetIsMenuButton() does not cause the button to do anything other than draw the menu indication..PPSee also isMenuButton()..SH "void QPushButton::setOn ( bool enable ) \fC[virtual slot]\fR"Switches a toggle button on if \fIenable\fR is TRUE or off if \fIenable\fR is FALSE..PPSee also isOn(), toggle(), toggled() and isToggleButton()..PPExamples:.(lqmag/qmag.cpp.)l.SH "void QPushButton::setPopup ( QPopupMenu * popup )"Associates the popup menu \fIpopup\fR with this push button and thus turns it into a menu button..PPOwnership of the popup menu is not transferred..PPSee also popup()..SH "void QPushButton::setToggleButton ( bool enable ) \fC[virtual]\fR"Makes the push button a toggle button if \fIenable\fR is TRUE, or a normal push button if \fIenable\fR is FALSE..PPToggle buttons have an on/off state similar to check boxes. A push button is initially not a toggle button..PPSee also setOn(), toggle(), isToggleButton() and toggled()..PPExamples:.(lqmag/qmag.cpp.)l.SH "QSize QPushButton::sizeHint () const \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "QSizePolicy QPushButton::sizePolicy () const \fC[virtual]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "void QPushButton::toggle () \fC[important inherited]\fR"Toggles the state of a toggle button..PPSee also isOn(), setOn(), toggled() and isToggleButton()..SH "void QPushButton::updateMask () \fC[virtual protected]\fR"Reimplemented for internal reasons; the API is not affected..PPReimplemented from QWidget..SH "SEE ALSO".BR http://doc.trolltech.com/qpushbutton.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports make our job much simpler. Thank you..PIn case of content or formattting problems with this manual page, pleasereport them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qpushbutton.3qt) and the Qtversion (2.3.10).
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -