Home · All Classes · Main Classes · Grouped Classes · Modules · Functions

QToolTip Class Reference
[QtGui module]

The QToolTip class provides tooltips (balloon help) for any widget. More...

 #include <QToolTip>

Static Public Members


Detailed Description

The QToolTip class provides tooltips (balloon help) for any widget.

The tip is a short piece of text reminding the user of the widget's function. It is drawn immediately below the given position in a distinctive black-on-yellow color combination. The tip can be any rich text formatted string.

Rich text formatted tips implictely do word breaking, unless specified differently with <p style='white-space:pre'>.

The simplest and most common way to set a widget's tooltip is by calling its QWidget::setToolTip() function.

It is also possible to show different tooltips for different regions of a widget, by using a QHelpEvent of type QEvent::ToolTip. Intercept the help event in your widget's event() function and call QToolTip::showText() with the text you want to display. The Tooltips example illustrates this technique.

Note that if you want to show tooltips in an item view, the model/view architecture provides functionality to set an item's tootip, e.g., the QTableWidgetItem::setToolTip() function. But if you want to provide custom tooltips in an item view you must intercept the help event in the QAbstractItemView::viewportEvent() function instead.

The default tooltip color and font can be customized with setPalette() and setFont().

See also QWidget::toolTip, QAction::toolTip, and Tooltips Example.


Member Function Documentation

QFont QToolTip::font ()   [static]

Returns the font used to render tooltips.

This function was introduced in Qt 4.2.

See also setFont().

void QToolTip::hideText ()   [static]

Hides the tool tip. This is the same as calling showText() with an empty string.

This function was introduced in Qt 4.2.

See also showText().

QPalette QToolTip::palette ()   [static]

Returns the palette used to render tooltips.

See also setPalette().

void QToolTip::setFont ( const QFont & font )   [static]

Sets the font used to render tooltips.

This function was introduced in Qt 4.2.

See also font().

void QToolTip::setPalette ( const QPalette & palette )   [static]

Sets the palette used to render tooltips.

This function was introduced in Qt 4.2.

See also palette().

void QToolTip::showText ( const QPoint & pos, const QString & text, QWidget * w, const QRect & rect )   [static]

Shows text as a tool tip, at global position pos. If you specify a non-empty rect the tip will be hidden as soon as you move your cursor out of this area.

The rect is in the coordinates of the widget you specify with w. If the rect is not empty you must specify a widget. Otherwise this argument can be 0 but it is used to determine the appropriate screen on multi-head systems.

If text is empty the tool tip is hidden. If the text is the same as the currently shown tooltip, the tip will not move. You can force moving by first hiding the tip with an empty text, and then showing the new tip at the new position.

void QToolTip::showText ( const QPoint & pos, const QString & text, QWidget * w = 0 )   [static]

This is an overloaded member function, provided for convenience.

This is analogous to calling QToolTip::showText(pos, text, w, QRect())


Member Function Documentation

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

Use QWidget::setToolTip() instead.

For example, if you have code like

 tip->add(widget, text);

you can rewrite it as

 widget->setToolTip(text);

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

This is an overloaded member function, provided for convenience.

Intercept the QEvent::ToolTip events in your widget's QWidget::event() function and call QToolTip::showText() with the text you want to display. The Tooltips example illustrates this technique.

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

Use QWidget::setToolTip() instead.

For example, if you have code like

 tip->remove(widget);

you can rewrite it as

 widget->setToolTip("");


Copyright © 2007 Trolltech Trademarks
Qt 4.2.3