Eneboo - Documentación para desarrolladores
|
The QPushButton widget provides a command button. Más...
#include <qpushbutton.h>
Slots públicos | |
virtual void | setOn (bool) |
virtual void | setOn (bool) |
Métodos públicos | |
QPushButton (QWidget *parent, const char *name=0) | |
QPushButton (const QString &text, QWidget *parent, const char *name=0) | |
QPushButton (const QIconSet &icon, const QString &text, QWidget *parent, const char *name=0) | |
~QPushButton () | |
QSize | sizeHint () const |
void | move (int x, int y) |
void | move (const QPoint &p) |
void | resize (int w, int h) |
void | resize (const QSize &) |
void | setGeometry (int x, int y, int w, int h) |
void | setGeometry (const QRect &) |
void | setToggleButton (bool) |
bool | autoDefault () const |
virtual void | setAutoDefault (bool autoDef) |
bool | isDefault () const |
virtual void | setDefault (bool def) |
virtual void | setIsMenuButton (bool enable) |
bool | isMenuButton () const |
void | setPopup (QPopupMenu *popup) |
QPopupMenu * | popup () const |
void | setIconSet (const QIconSet &) |
QIconSet * | iconSet () const |
void | setFlat (bool) |
bool | isFlat () const |
QPushButton (QWidget *parent, const char *name=0) | |
QPushButton (const QString &text, QWidget *parent, const char *name=0) | |
QPushButton (const QIconSet &icon, const QString &text, QWidget *parent, const char *name=0) | |
~QPushButton () | |
QSize | sizeHint () const |
void | move (int x, int y) |
void | move (const QPoint &p) |
void | resize (int w, int h) |
void | resize (const QSize &) |
void | setGeometry (int x, int y, int w, int h) |
void | setGeometry (const QRect &) |
void | setToggleButton (bool) |
bool | autoDefault () const |
virtual void | setAutoDefault (bool autoDef) |
bool | isDefault () const |
virtual void | setDefault (bool def) |
virtual void | setIsMenuButton (bool enable) |
bool | isMenuButton () const |
void | setPopup (QPopupMenu *popup) |
QPopupMenu * | popup () const |
void | setIconSet (const QIconSet &) |
QIconSet * | iconSet () const |
void | setFlat (bool) |
bool | isFlat () const |
Métodos protegidos | |
void | drawButton (QPainter *) |
void | drawButtonLabel (QPainter *) |
void | focusInEvent (QFocusEvent *) |
void | focusOutEvent (QFocusEvent *) |
void | resizeEvent (QResizeEvent *) |
void | updateMask () |
void | drawButton (QPainter *) |
void | drawButtonLabel (QPainter *) |
void | focusInEvent (QFocusEvent *) |
void | focusOutEvent (QFocusEvent *) |
void | resizeEvent (QResizeEvent *) |
void | updateMask () |
Propiedades | |
bool | autoDefault |
whether the push button is the auto default button | |
bool | default |
whether the push button is the default button | |
bool | menuButton |
whether the push button has a menu button on it | |
QIconSet | iconSet |
the icon set on the push button | |
bool | flat |
whether the border is disabled | |
Amigas | |
class | QDialog |
The QPushButton widget provides a command button.
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.
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.
QPushButton *pb = new QPushButton( "&Download", this );
In this example the accelerator is {Alt+D}, and the label text will be displayed as <u>D</u>ownload.
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".
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().
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).
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.
The most important modes or states are: Available or not (grayed out, disabled). Standard push button, toggling push button or menu button. On or off (only for toggling push buttons). Default or normal. The default button in a dialog can generally be "clicked" using the Enter or Return key. Auto-repeat or not. Pressed down or not.
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) and 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. Qt provides a special class (QToolButton) 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.
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.
Other classes of buttons are option buttons (see QRadioButton) and check boxes (see QCheckBox).
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.
text, setText, text, pixmap, setPixmap, accel, setAccel, isToggleButton, setDown, isDown, isOn, state, autoRepeat, isExclusiveToggle, group, setAutoRepeat, toggle, pressed, released, clicked, toggled, state stateChanged
QPushButton::QPushButton | ( | QWidget * | parent, |
const char * | name = 0 |
||
) |
Constructs a push button with no text.
The parent and name arguments are sent on to the QWidget constructor.
Constructs a push button called name with the parent parent and the text text.
QPushButton::~QPushButton | ( | ) |
Destroys the push button.
QPushButton::QPushButton | ( | QWidget * | parent, |
const char * | name = 0 |
||
) |
QPushButton::QPushButton | ( | const QIconSet & | icon, |
const QString & | text, | ||
QWidget * | parent, | ||
const char * | name = 0 |
||
) |
QPushButton::~QPushButton | ( | ) |
bool QPushButton::autoDefault | ( | ) | const [inline] |
bool QPushButton::autoDefault | ( | ) | const [inline] |
void QPushButton::drawButton | ( | QPainter * | ) | [protected, virtual] |
Draws the button. The default implementation does nothing.
This virtual function is reimplemented by subclasses to draw real buttons. At some point, these reimplementations should call drawButtonLabel().
Reimplementado de QButton.
void QPushButton::drawButtonLabel | ( | QPainter * | paint | ) | [protected, virtual] |
Reimplementado de QButton.
Reimplementado en QwtArrowButton.
void QPushButton::drawButtonLabel | ( | QPainter * | ) | [protected, virtual] |
Draws the button text or pixmap.
This virtual function is reimplemented by subclasses to draw real buttons. It is invoked by drawButton().
Reimplementado de QButton.
Reimplementado en QwtArrowButton.
void QPushButton::focusInEvent | ( | QFocusEvent * | e | ) | [protected, virtual] |
Reimplementado de QButton.
void QPushButton::focusInEvent | ( | QFocusEvent * | e | ) | [protected, virtual] |
Reimplementado de QButton.
void QPushButton::focusOutEvent | ( | QFocusEvent * | e | ) | [protected, virtual] |
Reimplementado de QButton.
void QPushButton::focusOutEvent | ( | QFocusEvent * | e | ) | [protected, virtual] |
Reimplementado de QButton.
QIconSet* QPushButton::iconSet | ( | ) | const |
QIconSet* QPushButton::iconSet | ( | ) | const |
bool QPushButton::isDefault | ( | ) | const [inline] |
bool QPushButton::isDefault | ( | ) | const [inline] |
bool QPushButton::isFlat | ( | ) | const |
bool QPushButton::isFlat | ( | ) | const |
bool QPushButton::isMenuButton | ( | ) | const [inline] |
bool QPushButton::isMenuButton | ( | ) | const [inline] |
QPopupMenu * QPushButton::popup | ( | ) | const |
Returns the button's associated popup menu or 0 if no popup menu has been set.
QPopupMenu* QPushButton::popup | ( | ) | const |
void QPushButton::resizeEvent | ( | QResizeEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive widget resize events. When resizeEvent() is called, the widget already has its new geometry. The old size is accessible through QResizeEvent::oldSize().
The widget will be erased and receive a paint event immediately after processing the resize event. No drawing need be (or should be) done inside this handler.
Widgets that have been created with the WNoAutoErase
flag will not be erased. Nevertheless, they will receive a paint event for their entire area afterwards. Again, no drawing needs to be done inside this handler.
The default implementation calls updateMask() if the widget has automatic masking enabled.
Reimplementado de QWidget.
void QPushButton::resizeEvent | ( | QResizeEvent * | ) | [protected, virtual] |
Reimplementado de QWidget.
virtual void QPushButton::setAutoDefault | ( | bool | autoDef | ) | [virtual] |
void QPushButton::setAutoDefault | ( | bool | autoDef | ) | [virtual] |
virtual void QPushButton::setDefault | ( | bool | def | ) | [virtual] |
void QPushButton::setDefault | ( | bool | def | ) | [virtual] |
void QPushButton::setFlat | ( | bool | ) |
void QPushButton::setFlat | ( | bool | f | ) |
void QPushButton::setIconSet | ( | const QIconSet & | ) |
void QPushButton::setIconSet | ( | const QIconSet & | icon | ) |
void QPushButton::setIsMenuButton | ( | bool | enable | ) | [inline, virtual] |
virtual void QPushButton::setIsMenuButton | ( | bool | enable | ) | [inline, virtual] |
void QPushButton::setOn | ( | bool | on | ) | [virtual, slot] |
Sets the state of this button to On if on is TRUE; otherwise to Off.
Reimplementado de QButton.
virtual void QPushButton::setOn | ( | bool | on | ) | [virtual, slot] |
Sets the state of this button to On if on is TRUE; otherwise to Off.
Reimplementado de QButton.
void QPushButton::setPopup | ( | QPopupMenu * | popup | ) |
void QPushButton::setPopup | ( | QPopupMenu * | popup | ) |
Associates the popup menu popup with this push button. This turns the button into a menu button.
Ownership of the popup menu is not transferred to the push button.
void QPushButton::setToggleButton | ( | bool | b | ) |
If b is TRUE, this button becomes a toggle button; if b is FALSE, this button becomes a command button.
Reimplementado de QButton.
void QPushButton::setToggleButton | ( | bool | b | ) |
If b is TRUE, this button becomes a toggle button; if b is FALSE, this button becomes a command button.
Reimplementado de QButton.
QSize QPushButton::sizeHint | ( | ) | const [virtual] |
Reimplementado de QWidget.
Reimplementado en QwtArrowButton.
QSize QPushButton::sizeHint | ( | ) | const [virtual] |
Reimplementado de QWidget.
Reimplementado en QwtArrowButton.
void QPushButton::updateMask | ( | ) | [protected, virtual] |
This function can be reimplemented in a subclass to support transparent widgets. It should be called whenever a widget changes state in a way that means that the shape mask must be recalculated.
Reimplementado de QWidget.
void QPushButton::updateMask | ( | ) | [protected, virtual] |
Reimplementado de QWidget.
QDialog [friend] |
bool QPushButton::autoDefault [read, write] |
whether the push button is the auto default button
If this property is set to TRUE then the push button is the auto default button in a dialog.
In 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.
This property's default is TRUE for buttons that have a QDialog parent; otherwise it defaults to FALSE.
See the default property for details of how default and auto-default interact.
bool QPushButton::default [read, write] |
whether the push button is the default button
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.
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.
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).
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.
This property's default is FALSE.
bool QPushButton::flat [read, write] |
whether the border is disabled
This property's default is FALSE.
QIconSet QPushButton::iconSet [read, write] |
the icon set on the push button
This property will return 0 if the push button has no iconset.
bool QPushButton::menuButton [read] |
whether the push button has a menu button on it
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.