Eneboo - Documentación para desarrolladores
Métodos públicos | Métodos públicos estáticos | Métodos protegidos | Amigas
Referencia de la Clase QToolTip

The QToolTip class provides tool tips (balloon help) for any widget or rectangular part of a widget. Más...

#include <qtooltip.h>

Diagrama de herencias de QToolTip
Qt Qt QHideToolTip QIconViewToolTip QListViewToolTip QSAEditorToolTip QTabBarToolTip QTitleBarTip

Lista de todos los miembros.

Métodos públicos

 QToolTip (QWidget *, QToolTipGroup *=0)
QWidgetparentWidget () const
QToolTipGroupgroup () const
 QToolTip (QWidget *, QToolTipGroup *=0)
QWidgetparentWidget () const
QToolTipGroupgroup () const

Métodos públicos estáticos

static void add (QWidget *, const QString &)
static void add (QWidget *, const QString &, QToolTipGroup *, const QString &)
static void remove (QWidget *)
static void add (QWidget *, const QRect &, const QString &)
static void add (QWidget *, const QRect &, const QString &, QToolTipGroup *, const QString &)
static void remove (QWidget *, const QRect &)
static QString textFor (QWidget *, const QPoint &pos=QPoint())
static void hide ()
static QFont font ()
static void setFont (const QFont &)
static QPalette palette ()
static void setPalette (const QPalette &)
static void setEnabled (bool enable)
static bool enabled ()
static void setGloballyEnabled (bool)
static bool isGloballyEnabled ()
static void setWakeUpDelay (int)
static void add (QWidget *, const QString &)
static void add (QWidget *, const QString &, QToolTipGroup *, const QString &)
static void remove (QWidget *)
static void add (QWidget *, const QRect &, const QString &)
static void add (QWidget *, const QRect &, const QString &, QToolTipGroup *, const QString &)
static void remove (QWidget *, const QRect &)
static QString textFor (QWidget *, const QPoint &pos=QPoint())
static void hide ()
static QFont font ()
static void setFont (const QFont &)
static QPalette palette ()
static void setPalette (const QPalette &)
static void setEnabled (bool enable)
static bool enabled ()
static void setGloballyEnabled (bool)
static bool isGloballyEnabled ()
static void setWakeUpDelay (int)

Métodos protegidos

virtual void maybeTip (const QPoint &)=0
void tip (const QRect &, const QString &)
void tip (const QRect &, const QString &, const QString &)
void tip (const QRect &, const QString &, const QRect &)
void tip (const QRect &, const QString &, const QString &, const QRect &)
void clear ()
virtual void maybeTip (const QPoint &)=0
void tip (const QRect &, const QString &)
void tip (const QRect &, const QString &, const QString &)
void tip (const QRect &, const QString &, const QRect &)
void tip (const QRect &, const QString &, const QString &, const QRect &)
void clear ()

Amigas

class QTipManager

Descripción detallada

The QToolTip class provides tool tips (balloon help) for any widget or rectangular part of a widget.

The tip is a short, single line of text reminding the user of the widget's or rectangle's function. It is drawn immediately below the region in a distinctive black-on-yellow combination.

The tip can be any Rich-Text formatted string.

QToolTipGroup provides a way for tool tips to display another text elsewhere (most often in a status bar).

At any point in time, QToolTip is either dormant or active. In dormant mode the tips are not shown and in active mode they are. The mode is global, not particular to any one widget.

QToolTip switches from dormant to active mode when the user hovers the mouse on a tip-equipped region for a second or so and remains active until the user either clicks a mouse button, presses a key, lets the mouse hover for five seconds or moves the mouse outside all tip-equipped regions for at least a second.

The QToolTip class can be used in three different ways: 1 Adding a tip to an entire widget. Adding a tip to a fixed rectangle within a widget. Adding a tip to a dynamic rectangle within a widget.

To add a tip to a widget, call the static function QToolTip::add() with the widget and tip as arguments:

        QToolTip::add( quitButton, "Leave the application" );

This is the simplest and most common use of QToolTip. The tip will be deleted automatically when quitButton is deleted, but you can remove it yourself, too:

        QToolTip::remove( quitButton );

You can also display another text (typically in a status bar), courtesy of {QToolTipGroup}. This example assumes that grp is a {QToolTipGroup *} and is already connected to the appropriate status bar:

        QToolTip::add( quitButton, "Leave the application", grp,
                       "Leave the application, prompting to save if necessary" );
        QToolTip::add( closeButton, "Close this window", grp,
                       "Close this window, prompting to save if necessary" );

To add a tip to a fixed rectangle within a widget, call the static function QToolTip::add() with the widget, rectangle and tip as arguments. (See the tooltip/tooltip.cpp example.) Again, you can supply a {QToolTipGroup *} and another text if you want.

Both of these are one-liners and cover the majority of cases. The third and most general way to use QToolTip requires you to reimplement a pure virtual function to decide whether to pop up a tool tip. The tooltip/tooltip.cpp example demonstrates this too. This mode can be used to implement tips for text that can move as the user scrolls, for example.

To use QToolTip like this, you must subclass QToolTip and reimplement maybeTip(). QToolTip calls maybeTip() when a tip should pop up, and maybeTip() decides whether to show a tip.

Tool tips can be globally disabled using QToolTip::setGloballyEnabled() or disabled in groups with QToolTipGroup::setEnabled().

You can retrieve the text of a tooltip for a given position within a widget using textFor().

The global tooltip font and palette can be set with the static setFont() and setPalette() functions respectively.

Ver también:
QStatusBar QWhatsThis QToolTipGroup GUI Design Handbook: Tool Tip

Documentación del constructor y destructor

QToolTip::QToolTip ( QWidget widget,
QToolTipGroup group = 0 
)

Constructs a tool tip object. This is only necessary if you need tool tips on regions that can move within the widget (most often because the widget's contents can scroll).

widget is the widget you want to add dynamic tool tips to and group (optional) is the tool tip group they should belong to.

Atención:
QToolTip is not a subclass of QObject, so the instance of QToolTip is not deleted when widget is deleted.
If you delete the tool tip before you have deleted widget then you need to make sure you call remove() yourself from widget in your reimplemented QToolTip destructor.
        MyToolTip::~MyToolTip()
        {
            remove( widget );
        }
Ver también:
maybeTip().
QToolTip::QToolTip ( QWidget ,
QToolTipGroup = 0 
)

Documentación de las funciones miembro

void QToolTip::add ( QWidget widget,
const QString text 
) [static]

Adds a tool tip to widget. text is the text to be shown in the tool tip.

This is the most common entry point to the QToolTip class; it is suitable for adding tool tips to buttons, checkboxes, comboboxes and so on.

void QToolTip::add ( QWidget widget,
const QString text,
QToolTipGroup group,
const QString longText 
) [static]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Adds a tool tip to widget and to tool tip group group.

text is the text shown in the tool tip and longText is the text emitted from group.

Normally, longText is shown in a status bar or similar.

void QToolTip::add ( QWidget widget,
const QRect rect,
const QString text 
) [static]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Adds a tool tip to a fixed rectangle, rect, within widget. text is the text shown in the tool tip.

void QToolTip::add ( QWidget widget,
const QRect rect,
const QString text,
QToolTipGroup group,
const QString groupText 
) [static]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Adds a tool tip to an entire widget and to tool tip group group. The tooltip will disappear when the mouse leaves the rect.

text is the text shown in the tool tip and groupText is the text emitted from group.

Normally, groupText is shown in a status bar or similar.

static void QToolTip::add ( QWidget ,
const QString  
) [static]
static void QToolTip::add ( QWidget ,
const QString ,
QToolTipGroup ,
const QString  
) [static]
static void QToolTip::add ( QWidget ,
const QRect ,
const QString  
) [static]
static void QToolTip::add ( QWidget ,
const QRect ,
const QString ,
QToolTipGroup ,
const QString  
) [static]
void QToolTip::clear ( void  ) [protected]

Immediately removes all tool tips for this tooltip's parent widget.

void QToolTip::clear ( ) [protected]
static bool QToolTip::enabled ( ) [inline, static]
static bool QToolTip::enabled ( ) [inline, static]
static QFont QToolTip::font ( ) [static]
QFont QToolTip::font ( ) [static]

Returns the font common to all tool tips.

Ver también:
setFont()
QToolTipGroup* QToolTip::group ( ) const [inline]
QToolTipGroup * QToolTip::group ( ) const [inline]

Returns the tool tip group this QToolTip is a member of or 0 if it isn't a member of any group.

The tool tip group is the object responsible for maintaining contact between tool tips and a status bar or something else which can show the longer help text.

Ver también:
parentWidget(), QToolTipGroup
static void QToolTip::hide ( ) [static]
void QToolTip::hide ( ) [static]

Hides any tip that is currently being shown.

Normally, there is no need to call this function; QToolTip takes care of showing and hiding the tips as the user moves the mouse.

bool QToolTip::isGloballyEnabled ( ) [static]

Returns whether tool tips are enabled globally.

Ver también:
setGloballyEnabled()
static bool QToolTip::isGloballyEnabled ( ) [static]
void QToolTip::maybeTip ( const QPoint p) [protected, pure virtual]

This pure virtual function is half of the most versatile interface QToolTip offers.

It is called when there is a possibility that a tool tip should be shown and must decide whether there is a tool tip for the point p in the widget that this QToolTip object relates to. If so, maybeTip() must call tip() with the rectangle the tip applies to, the tip's text and optionally the QToolTipGroup details and the geometry in screen coordinates.

p is given in that widget's local coordinates. Most maybeTip() implementations will be of the form:

        if ( <something> ) {
            tip( <something>, <something> );
        }

The first argument to tip() (a rectangle) must encompass p, i.e. the tip must apply to the current mouse position; otherwise QToolTip's operation is undefined.

Note that the tip will disappear once the mouse moves outside the rectangle you give to tip(), and will not reappear if the mouse moves back in: maybeTip() is called again instead.

Ver también:
tip()

Implementado en QSAEditorToolTip, QIconViewToolTip, QListViewToolTip, QHideToolTip, QTabBarToolTip y QTitleBarTip.

virtual void QToolTip::maybeTip ( const QPoint ) [protected, pure virtual]
static QPalette QToolTip::palette ( ) [static]
QPalette QToolTip::palette ( ) [static]

Returns the palette common to all tool tips.

Ver también:
setPalette()
QWidget* QToolTip::parentWidget ( ) const [inline]
QWidget * QToolTip::parentWidget ( ) const [inline]

Returns the widget this QToolTip applies to.

The tool tip is destroyed automatically when the parent widget is destroyed.

Ver también:
group()
void QToolTip::remove ( QWidget widget,
const QRect rect 
) [static]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Removes any tool tip for rect from widget.

If there is more than one tool tip on widget, only the one covering rectangle rect is removed.

void QToolTip::remove ( QWidget widget) [static]

Removes the tool tip from widget.

If there is more than one tool tip on widget, only the one covering the entire widget is removed.

static void QToolTip::remove ( QWidget ) [static]
static void QToolTip::remove ( QWidget ,
const QRect  
) [static]
static void QToolTip::setEnabled ( bool  enable) [inline, static]
static void QToolTip::setEnabled ( bool  enable) [inline, static]
static void QToolTip::setFont ( const QFont ) [static]
void QToolTip::setFont ( const QFont font) [static]

Sets the font for all tool tips to font.

Ver también:
font()
void QToolTip::setGloballyEnabled ( bool  enable) [static]

If enable is TRUE sets all tool tips to be enabled (shown when needed); if enable is FALSE sets all tool tips to be disabled (never shown).

By default, tool tips are enabled. Note that this function affects all tool tips in the entire application.

Ver también:
QToolTipGroup::setEnabled()
static void QToolTip::setGloballyEnabled ( bool  ) [static]
void QToolTip::setPalette ( const QPalette palette) [static]

Sets the palette for all tool tips to palette.

Ver también:
palette()
static void QToolTip::setPalette ( const QPalette ) [static]
static void QToolTip::setWakeUpDelay ( int  ) [static]
void QToolTip::setWakeUpDelay ( int  i) [static]

Sets the wakeup delay for all tooltips to i milliseconds.

QString QToolTip::textFor ( QWidget widget,
const QPoint pos = QPoint() 
) [static]

Returns the tool tip text for widget at position pos, or QString::null if there is no tool tip for the given widget and position.

static QString QToolTip::textFor ( QWidget ,
const QPoint pos = QPoint() 
) [static]
void QToolTip::tip ( const QRect rect,
const QString text,
const QRect geometry 
) [protected]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Immediately pops up a tip within the rectangle geometry, saying text and removes the tip once the cursor moves out of rectangle rect. Both rectangles are given in the coordinate system of the widget this QToolTip relates to.

The tip will not reappear if the cursor moves back; your maybeTip() must reinstate it each time.

If the tip does not fit inside geometry, the tip expands.

void QToolTip::tip ( const QRect rect,
const QString text,
const QString groupText,
const QRect geometry 
) [protected]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Immediately pops up a tip within the rectangle geometry, saying text and removes the tip once the cursor moves out of rectangle rect. groupText is the text emitted from the group. Both rectangles are given in the coordinate system of the widget this QToolTip relates to.

The tip will not reappear if the cursor moves back; your maybeTip() must reinstate it each time.

If the tip does not fit inside geometry, the tip expands.

void QToolTip::tip ( const QRect ,
const QString ,
const QRect  
) [protected]
void QToolTip::tip ( const QRect ,
const QString ,
const QString ,
const QRect  
) [protected]
void QToolTip::tip ( const QRect ,
const QString ,
const QString  
) [protected]
void QToolTip::tip ( const QRect rect,
const QString text 
) [protected]

Immediately pops up a tip saying text and removes the tip once the cursor moves out of rectangle rect (which is given in the coordinate system of the widget this QToolTip relates to).

The tip will not reappear if the cursor moves back; your maybeTip() must reinstate it each time.

void QToolTip::tip ( const QRect rect,
const QString text,
const QString groupText 
) [protected]

Esta es una función miembro sobrecargada que se suministra por conveniencia. Difiere de la anterior función solamente en los argumentos que acepta. Immediately pops up a tip saying text and removes that tip once the cursor moves out of rectangle rect (which is given in the coordinate system of the widget this QToolTip relates to). groupText is the text emitted from the group.

The tip will not reappear if the cursor moves back; your maybeTip() must reinstate it each time.

void QToolTip::tip ( const QRect ,
const QString  
) [protected]

Documentación de las funciones relacionadas y clases amigas

QTipManager [friend]

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'