Eneboo - Documentación para desarrolladores
|
The QToolButton class provides a quick-access button to commands or options, usually used inside a QToolBar. Más...
#include <qtoolbutton.h>
Tipos públicos | |
enum | TextPosition { BesideIcon, BelowIcon, Right = BesideIcon, Under = BelowIcon, BesideIcon, BelowIcon, Right = BesideIcon, Under = BelowIcon } |
enum | TextPosition { BesideIcon, BelowIcon, Right = BesideIcon, Under = BelowIcon, BesideIcon, BelowIcon, Right = BesideIcon, Under = BelowIcon } |
Slots públicos | |
virtual void | setUsesBigPixmap (bool enable) |
virtual void | setUsesTextLabel (bool enable) |
virtual void | setTextLabel (const QString &, bool) |
virtual void | setToggleButton (bool enable) |
virtual void | setOn (bool enable) |
void | toggle () |
void | setTextLabel (const QString &) |
void | setTextPosition (TextPosition pos) |
virtual void | setUsesBigPixmap (bool enable) |
virtual void | setUsesTextLabel (bool enable) |
virtual void | setTextLabel (const QString &, bool) |
virtual void | setToggleButton (bool enable) |
virtual void | setOn (bool enable) |
void | toggle () |
void | setTextLabel (const QString &) |
void | setTextPosition (TextPosition pos) |
Métodos públicos | |
QToolButton (QWidget *parent, const char *name=0) | |
QToolButton (const QIconSet &s, const QString &textLabel, const QString &grouptext, QObject *receiver, const char *slot, QToolBar *parent, const char *name=0) | |
QToolButton (ArrowType type, QWidget *parent, const char *name=0) | |
~QToolButton () | |
QSize | sizeHint () const |
QSize | minimumSizeHint () const |
void | setOnIconSet (const QIconSet &) |
void | setOffIconSet (const QIconSet &) |
void | setIconSet (const QIconSet &, bool on) |
QIconSet | onIconSet () const |
QIconSet | offIconSet () const |
QIconSet | iconSet (bool on) const |
virtual void | setIconSet (const QIconSet &) |
QIconSet | iconSet () const |
bool | usesBigPixmap () const |
bool | usesTextLabel () const |
QString | textLabel () const |
void | setPopup (QPopupMenu *popup) |
QPopupMenu * | popup () const |
void | setPopupDelay (int delay) |
int | popupDelay () const |
void | openPopup () |
void | setAutoRaise (bool enable) |
bool | autoRaise () const |
TextPosition | textPosition () const |
void | setText (const QString &txt) |
QToolButton (QWidget *parent, const char *name=0) | |
QToolButton (const QIconSet &s, const QString &textLabel, const QString &grouptext, QObject *receiver, const char *slot, QToolBar *parent, const char *name=0) | |
QToolButton (ArrowType type, QWidget *parent, const char *name=0) | |
~QToolButton () | |
QSize | sizeHint () const |
QSize | minimumSizeHint () const |
void | setOnIconSet (const QIconSet &) |
void | setOffIconSet (const QIconSet &) |
void | setIconSet (const QIconSet &, bool on) |
QIconSet | onIconSet () const |
QIconSet | offIconSet () const |
QIconSet | iconSet (bool on) const |
virtual void | setIconSet (const QIconSet &) |
QIconSet | iconSet () const |
bool | usesBigPixmap () const |
bool | usesTextLabel () const |
QString | textLabel () const |
void | setPopup (QPopupMenu *popup) |
QPopupMenu * | popup () const |
void | setPopupDelay (int delay) |
int | popupDelay () const |
void | openPopup () |
void | setAutoRaise (bool enable) |
bool | autoRaise () const |
TextPosition | textPosition () const |
void | setText (const QString &txt) |
Métodos protegidos | |
void | mousePressEvent (QMouseEvent *) |
void | drawButton (QPainter *) |
void | drawButtonLabel (QPainter *) |
void | enterEvent (QEvent *) |
void | leaveEvent (QEvent *) |
void | moveEvent (QMoveEvent *) |
bool | uses3D () const |
bool | eventFilter (QObject *o, QEvent *e) |
void | paletteChange (const QPalette &) |
void | mousePressEvent (QMouseEvent *) |
void | drawButton (QPainter *) |
void | drawButtonLabel (QPainter *) |
void | enterEvent (QEvent *) |
void | leaveEvent (QEvent *) |
void | moveEvent (QMoveEvent *) |
bool | uses3D () const |
bool | eventFilter (QObject *o, QEvent *e) |
void | paletteChange (const QPalette &) |
Propiedades | |
QIconSet | iconSet |
the icon set providing the icon shown on the button | |
QIconSet | onIconSet |
the icon set that is used when the button is in an "on" state | |
QIconSet | offIconSet |
the icon set that is used when the button is in an "off" state | |
bool | usesBigPixmap |
whether this toolbutton uses big pixmaps. | |
bool | usesTextLabel |
whether the toolbutton displays a text label below the button pixmap. | |
QString | textLabel |
the label of this button. | |
int | popupDelay |
the time delay between pressing the button and the appearance of the associated popup menu in milliseconds. | |
bool | autoRaise |
whether auto-raising is enabled or not. | |
TextPosition | textPosition |
the position of the text label of this button. |
The QToolButton class provides a quick-access button to commands or options, usually used inside a QToolBar.
A tool button is a special button that provides quick-access to specific commands or options. As opposed to a normal command button, a tool button usually doesn't show a text label, but shows an icon instead. Its classic usage is to select tools, for example the "pen" tool in a drawing program. This would be implemented with a QToolButton as toggle button (see setToggleButton() ).
QToolButton supports auto-raising. In auto-raise mode, the button draws a 3D frame only when the mouse points at it. The feature is automatically turned on when a button is used inside a QToolBar. Change it with setAutoRaise().
A tool button's icon is set as QIconSet. This makes it possible to specify different pixmaps for the disabled and active state. The disabled pixmap is used when the button's functionality is not available. The active pixmap is displayed when the button is auto-raised because the mouse pointer is hovering over it.
The button's look and dimension is adjustable with setUsesBigPixmap() and setUsesTextLabel(). When used inside a QToolBar in a QMainWindow, the button automatically adjusts to QMainWindow's settings (see QMainWindow::setUsesTextLabel() and QMainWindow::setUsesBigPixmaps()). The pixmap set on a QToolButton will be set to 22x22 if it is bigger than this size. If usesBigPixmap() is TRUE, then the pixmap will be set to 32x32.
A tool button can offer additional choices in a popup menu. The feature is sometimes used with the "Back" button in a web browser. After pressing and holding the button down for a while, a menu pops up showing a list of possible pages to jump to. With QToolButton you can set a popup menu using setPopup(). The default delay is 600ms; you can adjust it with setPopupDelay().
qdockwindow.png Toolbar with Toolbuttons A floating QToolbar with QToolbuttons
QToolButton::QToolButton | ( | QWidget * | parent, |
const char * | name = 0 |
||
) |
Constructs an empty tool button called name, with parent parent.
QToolButton::QToolButton | ( | const QIconSet & | iconSet, |
const QString & | textLabel, | ||
const QString & | grouptext, | ||
QObject * | receiver, | ||
const char * | slot, | ||
QToolBar * | parent, | ||
const char * | name = 0 |
||
) |
Constructs a tool button called name, that is a child of parent (which must be a QToolBar).
The tool button will display iconSet, with its text label and tool tip set to textLabel and its status bar message set to grouptext. It will be connected to the slot in object receiver.
Constructs a tool button as an arrow button. The ArrowType
type defines the arrow direction. Possible values are LeftArrow
, RightArrow
, UpArrow
and DownArrow
.
An arrow button has auto-repeat turned on by default.
The parent and name arguments are sent to the QWidget constructor.
QToolButton::~QToolButton | ( | ) |
Destroys the object and frees any allocated resources.
QToolButton::QToolButton | ( | QWidget * | parent, |
const char * | name = 0 |
||
) |
QToolButton::QToolButton | ( | const QIconSet & | s, |
const QString & | textLabel, | ||
const QString & | grouptext, | ||
QObject * | receiver, | ||
const char * | slot, | ||
QToolBar * | parent, | ||
const char * | name = 0 |
||
) |
QToolButton::~QToolButton | ( | ) |
bool QToolButton::autoRaise | ( | ) | const |
bool QToolButton::autoRaise | ( | ) | const |
void QToolButton::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 QToolButton::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.
void QToolButton::enterEvent | ( | QEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive widget enter events.
An event is sent to the widget when the mouse cursor enters the widget.
Reimplementado de QWidget.
Reimplementado de QObject.
Filters events if this object has been installed as an event filter for the watched object.
In your reimplementation of this function, if you want to filter the event e, out, i.e. stop it being handled further, return TRUE; otherwise return FALSE.
Example:
class MyMainWindow : public QMainWindow { public: MyMainWindow( QWidget *parent = 0, const char *name = 0 ); protected: bool eventFilter( QObject *obj, QEvent *ev ); private: QTextEdit *textEdit; }; MyMainWindow::MyMainWindow( QWidget *parent, const char *name ) : QMainWindow( parent, name ) { textEdit = new QTextEdit( this ); setCentralWidget( textEdit ); textEdit->installEventFilter( this ); } bool MyMainWindow::eventFilter( QObject *obj, QEvent *ev ) { if ( obj == textEdit ) { if ( e->type() == QEvent::KeyPress ) { QKeyEvent *k = (QKeyEvent*)ev; qDebug( "Ate key press %d", k->key() ); return TRUE; } else { return FALSE; } } else { // pass the event on to the parent class return QMainWindow::eventFilter( obj, ev ); } }
Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.
Reimplementado de QObject.
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.
Since Qt 3.0, QIconSet contains both the On and Off icons.
For ease of porting, this function ignores the on parameter and returns the iconSet property. If you relied on the on parameter, you probably want to update your code to use the QIconSet On/Off mechanism.
QIconSet QToolButton::iconSet | ( | ) | const |
QIconSet QToolButton::iconSet | ( | ) | const |
void QToolButton::leaveEvent | ( | QEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive widget leave events.
A leave event is sent to the widget when the mouse cursor leaves the widget.
Reimplementado de QWidget.
void QToolButton::mousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplementado de QButton.
void QToolButton::mousePressEvent | ( | QMouseEvent * | e | ) | [protected, virtual] |
Reimplementado de QButton.
void QToolButton::moveEvent | ( | QMoveEvent * | ) | [protected, virtual] |
This event handler can be reimplemented in a subclass to receive widget move events. When the widget receives this event, it is already at the new position.
The old position is accessible through QMoveEvent::oldPos().
Reimplementado de QWidget.
void QToolButton::moveEvent | ( | QMoveEvent * | ) | [protected, virtual] |
Reimplementado de QWidget.
QIconSet QToolButton::offIconSet | ( | ) | const |
QIconSet QToolButton::offIconSet | ( | ) | const |
QIconSet QToolButton::onIconSet | ( | ) | const |
QIconSet QToolButton::onIconSet | ( | ) | const |
void QToolButton::openPopup | ( | ) |
Opens (pops up) the associated popup menu. If there is no such menu, this function does nothing. This function does not return until the popup menu has been closed by the user.
void QToolButton::openPopup | ( | ) |
void QToolButton::paletteChange | ( | const QPalette & | ) | [protected, virtual] |
Reimplementado de QWidget.
void QToolButton::paletteChange | ( | const QPalette & | oldPalette | ) | [protected, virtual] |
This virtual function is called from setPalette(). oldPalette is the previous palette; you can get the new palette from palette().
Reimplement this function if your widget needs to know when its palette changes.
Reimplementado de QWidget.
QPopupMenu* QToolButton::popup | ( | ) | const |
QPopupMenu * QToolButton::popup | ( | ) | const |
Returns the associated popup menu, or 0 if no popup menu has been defined.
int QToolButton::popupDelay | ( | ) | const |
int QToolButton::popupDelay | ( | ) | const |
void QToolButton::setAutoRaise | ( | bool | enable | ) |
void QToolButton::setAutoRaise | ( | bool | enable | ) |
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta.
Since Qt 3.0, QIconSet contains both the On and Off icons.
For ease of porting, this function ignores the on parameter and sets the iconSet property. If you relied on the on parameter, you probably want to update your code to use the QIconSet On/Off mechanism.
void QToolButton::setIconSet | ( | const QIconSet & | set | ) | [virtual] |
virtual void QToolButton::setIconSet | ( | const QIconSet & | ) | [virtual] |
void QToolButton::setOffIconSet | ( | const QIconSet & | set | ) |
void QToolButton::setOffIconSet | ( | const QIconSet & | ) |
void QToolButton::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 QToolButton::setOn | ( | bool | on | ) | [virtual, slot] |
Sets the state of this button to On if on is TRUE; otherwise to Off.
Reimplementado de QButton.
void QToolButton::setOnIconSet | ( | const QIconSet & | ) |
void QToolButton::setOnIconSet | ( | const QIconSet & | set | ) |
void QToolButton::setPopup | ( | QPopupMenu * | popup | ) |
Associates the popup menu popup with this tool button.
The popup will be shown each time the tool button has been pressed down for a certain amount of time. A typical application example is the "back" button in some web browsers's tool bars. If the user clicks it, the browser simply browses back to the previous page. If the user presses and holds the button down for a while, the tool button shows a menu containing the current history list.
Ownership of the popup menu is not transferred to the tool button.
void QToolButton::setPopup | ( | QPopupMenu * | popup | ) |
void QToolButton::setPopupDelay | ( | int | delay | ) |
void QToolButton::setPopupDelay | ( | int | delay | ) |
void QToolButton::setTextLabel | ( | const QString & | newLabel | ) | [slot] |
void QToolButton::setTextLabel | ( | const QString & | ) | [slot] |
Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Sets the label of this button to newLabel and automatically sets it as a tool tip if tipToo is TRUE.
void QToolButton::setTextPosition | ( | TextPosition | pos | ) | [slot] |
void QToolButton::setTextPosition | ( | TextPosition | pos | ) | [slot] |
virtual void QToolButton::setToggleButton | ( | bool | b | ) | [virtual, slot] |
If b is TRUE, this button becomes a toggle button; if b is FALSE, this button becomes a command button.
Reimplementado de QButton.
void QToolButton::setToggleButton | ( | bool | b | ) | [virtual, slot] |
If b is TRUE, this button becomes a toggle button; if b is FALSE, this button becomes a command button.
Reimplementado de QButton.
virtual void QToolButton::setUsesBigPixmap | ( | bool | enable | ) | [virtual, slot] |
void QToolButton::setUsesBigPixmap | ( | bool | enable | ) | [virtual, slot] |
void QToolButton::setUsesTextLabel | ( | bool | enable | ) | [virtual, slot] |
virtual void QToolButton::setUsesTextLabel | ( | bool | enable | ) | [virtual, slot] |
QString QToolButton::textLabel | ( | ) | const [inline] |
QString QToolButton::textLabel | ( | ) | const [inline] |
TextPosition QToolButton::textPosition | ( | ) | const |
TextPosition QToolButton::textPosition | ( | ) | const |
void QToolButton::toggle | ( | ) | [slot] |
Toggles the state of a toggle button.
Reimplementado de QButton.
void QToolButton::toggle | ( | ) | [slot] |
Toggles the state of this tool button.
This function has no effect on non-toggling buttons.
Reimplementado de QButton.
bool QToolButton::uses3D | ( | ) | const [protected] |
Returns TRUE if this button should be drawn using raised edges; otherwise returns FALSE.
bool QToolButton::uses3D | ( | ) | const [protected] |
bool QToolButton::usesBigPixmap | ( | ) | const [inline] |
bool QToolButton::usesBigPixmap | ( | ) | const [inline] |
bool QToolButton::usesTextLabel | ( | ) | const [inline] |
bool QToolButton::usesTextLabel | ( | ) | const [inline] |
bool QToolButton::autoRaise [read, write] |
whether auto-raising is enabled or not.
The default is disabled (i.e. FALSE).
QIconSet QToolButton::iconSet [read, write] |
the icon set providing the icon shown on the button
Setting this property sets QToolButton::pixmap to a null pixmap. There is no default iconset.
QIconSet QToolButton::offIconSet [read, write] |
the icon set that is used when the button is in an "off" state
Since Qt 3.0, QIconSet contains both the On and Off icons. There is now an QToolButton::iconSet property that replaces both QToolButton::onIconSet and QToolButton::offIconSet.
For ease of porting, this property is a synonym for QToolButton::iconSet. You probably want to go over your application code and use the QIconSet On/Off mechanism.
QIconSet QToolButton::onIconSet [read, write] |
the icon set that is used when the button is in an "on" state
Since Qt 3.0, QIconSet contains both the On and Off icons. There is now an QToolButton::iconSet property that replaces both QToolButton::onIconSet and QToolButton::offIconSet.
For ease of porting, this property is a synonym for QToolButton::iconSet. You probably want to go over your application code and use the QIconSet On/Off mechanism.
int QToolButton::popupDelay [read, write] |
the time delay between pressing the button and the appearance of the associated popup menu in milliseconds.
Usually this is around half a second. A value of 0 draws the down arrow button to the side of the button which can be used to open up the popup menu.
QString QToolButton::textLabel [read, write] |
the label of this button.
Setting this property automatically sets the text as a tool tip too. There is no default text.
TextPosition QToolButton::textPosition [read, write] |
the position of the text label of this button.
bool QToolButton::usesBigPixmap [read, write] |
whether this toolbutton uses big pixmaps.
QToolButton automatically connects this property to the relevant signal in the QMainWindow in which it resides. We strongly recommend that you use QMainWindow::setUsesBigPixmaps() instead.
This property's default is TRUE.
bool QToolButton::usesTextLabel [read, write] |
whether the toolbutton displays a text label below the button pixmap.
The default is FALSE.
QToolButton automatically connects this slot to the relevant signal in the QMainWindow in which is resides.