Eneboo - Documentación para desarrolladores
Slots públicos | Métodos públicos | Métodos protegidos | Propiedades | Amigas
Referencia de la Clase QPushButton

The QPushButton widget provides a command button. Más...

#include <qpushbutton.h>

Diagrama de herencias de QPushButton
QButton QButton QWidget QWidget QWidget QWidget QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject QPaintDevice QObject ColorButton MyPushButton QDesignerPushButton QwtArrowButton

Lista de todos los miembros.

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)
QPopupMenupopup () const
void setIconSet (const QIconSet &)
QIconSeticonSet () 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)
QPopupMenupopup () const
void setIconSet (const QIconSet &)
QIconSeticonSet () 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

Descripción detallada

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).

qpushbt-m.png
qpushbt-w.png

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

Ver también:
QToolButton, QRadioButton QCheckBox GUI Design Handbook: Push Button

Documentación del constructor y destructor

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.

QPushButton::QPushButton ( const QString text,
QWidget parent,
const char *  name = 0 
)

Constructs a push button called name with the parent parent and the text text.

QPushButton::QPushButton ( const QIconSet icon,
const QString text,
QWidget parent,
const char *  name = 0 
)

Constructs a push button with an icon and a text.

Note that you can also pass a QPixmap object as an icon (thanks to the implicit type conversion provided by C++).

The parent and name arguments are sent to the QWidget constructor.

QPushButton::~QPushButton ( )

Destroys the push button.

QPushButton::QPushButton ( QWidget parent,
const char *  name = 0 
)
QPushButton::QPushButton ( const QString text,
QWidget parent,
const char *  name = 0 
)
QPushButton::QPushButton ( const QIconSet icon,
const QString text,
QWidget parent,
const char *  name = 0 
)
QPushButton::~QPushButton ( )

Documentación de las funciones miembro

bool QPushButton::autoDefault ( ) const [inline]
bool QPushButton::autoDefault ( ) const [inline]
void QPushButton::drawButton ( QPainter paint) [protected, virtual]

Reimplementado de QButton.

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().

Ver también:
drawButtonLabel(), paintEvent()

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().

Ver también:
drawButton(), paintEvent()

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]
void QPushButton::move ( int  x,
int  y 
) [virtual]

Reimplementado de QWidget.

void QPushButton::move ( const QPoint p)

Reimplementado de QWidget.

void QPushButton::move ( int  x,
int  y 
) [virtual]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. This corresponds to move( QPoint(x, y) ).

Reimplementado de QWidget.

void QPushButton::move ( const QPoint p)

Reimplementado de QWidget.

QPopupMenu * QPushButton::popup ( ) const

Returns the button's associated popup menu or 0 if no popup menu has been set.

Ver también:
setPopup()
QPopupMenu* QPushButton::popup ( ) const
void QPushButton::resize ( int  w,
int  h 
) [virtual]

Reimplementado de QWidget.

void QPushButton::resize ( const QSize )

Reimplementado de QWidget.

void QPushButton::resize ( const QSize s)

Reimplementado de QWidget.

void QPushButton::resize ( int  w,
int  h 
) [virtual]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. This corresponds to resize( QSize(w, h) ).

Reimplementado de QWidget.

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.

Ver también:
moveEvent(), event(), resize(), QResizeEvent, paintEvent()

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::setGeometry ( int  x,
int  y,
int  w,
int  h 
) [virtual]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. This corresponds to setGeometry( QRect(x, y, w, h) ).

Reimplementado de QWidget.

void QPushButton::setGeometry ( const QRect ) [virtual]

Reimplementado de QWidget.

void QPushButton::setGeometry ( int  x,
int  y,
int  w,
int  h 
) [virtual]

Reimplementado de QWidget.

void QPushButton::setGeometry ( const QRect r) [virtual]

Reimplementado de QWidget.

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.

Ver también:
toggleState

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.

Ver también:
toggleState

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.

Ver también:
popup()
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.

Ver también:
toggleButton

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.

Ver también:
toggleButton

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.

Ver también:
setAutoMask(), updateMask(), setMask(), clearMask()

Reimplementado de QWidget.

void QPushButton::updateMask ( ) [protected, virtual]

Reimplementado de QWidget.


Documentación de las funciones relacionadas y clases amigas

QDialog [friend]

Documentación de propiedades

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.


La documentación para esta clase fue generada a partir de los siguientes ficheros:
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'