QButton Class Reference


The QButton class is the base class of button widgets, and it provides functionality common to buttons. (details) (complete member list)

#include <qbutton.h>

Inherits QWidget.

Inherited by QCheckBox, QPushButton and QRadioButton.

Public Members

Signals

Protected Members


Detailed Description

The QButton class is the base class of button widgets, and it provides functionality common to buttons.

The QButton class implements an abstract button, and lets subclasses specify how to reply to user action and how to draw itself.

The QButton class has three signals. The pressed() signal is emitted when the left mouse button is pressed when the cursor is inside the button. After being pressed, the button will be down until the left mouse button is again released, which causes a released() signal. If the left mouse button is released when the cursor is inside the button, the clicked() signal will be emitted.

There are two types of buttons; standard buttons and toggle buttons. A standard button can either be pressed down or released. The QPushButton class is an example of a standard button. A toggle button has an additional flag that is toggled each time the button is clicked. The QRadioButton and QCheckBox classes are examples of toggle buttons.

Enabling auto-resizing will make a label resize itself whenever the contents change.


Member Function Documentation

QButton::QButton (QWidget *parent=0, const char *name=0)

Constructs a standard button with a parent widget and a name.

QButton::~QButton ()

Destroys the button and all its child widgets.

void QButton::adjustSize ()

Virtual function that adjusts the size of the button to fit the contents.

This function is called automatically whenever the contents change and auto-resizing is enabled.

See also: setAutoResizing(). Reimplemented in QCheckBox, QPushButton and QRadioButton.

bool QButton::autoResizing () const

Returns TRUE if auto-resizing is enabled, or FALSE if auto-resizing is disabled.

Auto-resizing is disabled by default.

See also: setAutoResizing().

void QButton::clicked ()

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

void QButton::drawButton (QPainter *)

Draws the button. The default implementation does nothing.

This virtual function is reimplemented by subclasses to draw real buttons. Reimplemented in QCheckBox, QPushButton and QRadioButton.

bool QButton::hitButton (const QPoint &pos) const

Returns TRUE if pos is inside the widget rectangle, or FALSE if it is outside.

This virtual function is reimplemented by subclasses.

bool QButton::isDown () const

Returns TRUE of the button is pressed down, the opposite of isUp().

bool QButton::isOn () const

Returns TRUE if this toggle button has been switched ON, or FALSE if it has been switched OFF.

See also: switchOn(), switchOff(), isOn().

bool QButton::isUp () const

Returns TRUE of the button is standing up, the opposite of isDown().

void QButton::mouseMoveEvent (QMouseEvent *e)

Internal handling of mouse move events.

void QButton::mousePressEvent (QMouseEvent *e)

Internal handling of mouse press events.

void QButton::mouseReleaseEvent (QMouseEvent *e)

Internal handling of mouse release events.

void QButton::paintEvent (QPaintEvent *)

Paints the button.

Opens the painter on the button and calls drawButton().

void QButton::pressed ()

This signal is emitted when the button is pressed down.

void QButton::released ()

This signal is emitted when the button is released.

void QButton::setAutoResizing (bool enable)

Enables auto-resizing if enable is TRUE, or disables it if enable is FALSE.

When auto-resizing is enabled, the button will resize itself whenever the contents change.

See also: autoResizing() and adjustSize().

void QButton::setText (const char *text)

Sets the button text to text and redraws the contents.

The button resizes itself if auto-resizing is enabled.

See also: setAutoResize().

void QButton::setToggleButton (bool toggle)

Sets the button to become a toggle button if toggle is TRUE, or a standard button if toggle is FALSE.

A button is initially a standard button.

See also: toggleButton().

void QButton::switchOff ()

Swithes a toggle button OFF. This function should be called only for toggle buttons.

See also: switchOn(), isOn().

void QButton::switchOn ()

Swithes a toggle button ON. This function should be called only for toggle buttons.

See also: switchOff(), isOn().

const char * QButton::text () const

Returns the button text.

bool QButton::toggleButton () const

Returns TRUE if the button is a toggle button.

See also: setToggleButton().


This file is part of the Qt toolkit, copyright 1995 Troll Tech, all rights reserved.

It was generated from the following files:


Generated at 16:17, 1995/06/30 by the webmaster at Troll Tech