The QToolTip class provides tool tips (balloon help) for any widget or rectangular part of a widget.
.PP
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.
.PP
The tip can be any Rich-Text formatted string.
.PP
QToolTipGroup provides a way for tool tips to display another text elsewhere (most often in a status bar).
.PP
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 \fIall\fR tip-equipped regions for at least a second.
This is the simplest and most common use of QToolTip. The tip will be deleted automatically when \fIquitButton\fR is deleted, but you can remove it yourself, too:
You can also display another text (typically in a status bar), courtesy of QToolTipGroup. This example assumes that \fIgrp\fR is a \fCQToolTipGroup *\fR and is already connected to the appropriate status bar:
"Leave the application, prompting to save if necessary" );
.br
QToolTip::add( closeButton, "Close this window", grp,
.br
"Close this window, prompting to save if necessary" );
.br
.fi
.PP
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 \fCQToolTipGroup *\fR 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.
.PP
Tool tips can be globally disabled using QToolTip::setGloballyEnabled() or disabled in groups with QToolTipGroup::setEnabled().
.PP
You can retrieve the text of a tooltip for a given position within a widget using textFor().
.PP
The global tooltip font and palette can be set with the static setFont() and setPalette() functions respectively.
.PP
See also QStatusBar, QWhatsThis, QToolTipGroup, GUI Design Handbook: Tool Tip, and Help System.
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).
.PP
\fIwidget\fR is the widget you want to add dynamic tool tips to and \fIgroup\fR (optional) is the tool tip group they should belong to.
.PP
\fBWarning:\fR QToolTip is not a subclass of QObject, so the instance of QToolTip is not deleted when \fIwidget\fR is deleted.
.PP
\fBWarning:\fR If you delete the tool tip before you have deleted \fIwidget\fR then you need to make sure you call remove() yourself from \fIwidget\fR in your reimplemented QToolTip destructor.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Adds a tool tip to an entire \fIwidget\fR and to tool tip group \fIgroup\fR. The tooltip will disappear when the mouse leaves the \fIrect\fR.
.PP
\fItext\fR is the text shown in the tool tip and \fIgroupText\fR is the text emitted from \fIgroup\fR.
.PP
Normally, \fIgroupText\fR is shown in a status bar or similar.
.SH "void QToolTip::clear ()\fC [protected]\fR"
Immediately removes all tool tips for this tooltip's parent widget.
.SH "bool QToolTip::enabled ()\fC [static]\fR"
\fBThis function is obsolete.\fR It is provided to keep old source working. We strongly advise against using it in new code.
.SH "QFont QToolTip::font ()\fC [static]\fR"
Returns the font common to all tool tips.
.PP
See also setFont().
.SH "QToolTipGroup * QToolTip::group () const"
Returns the tool tip group this QToolTip is a member of or 0 if it isn't a member of any group.
.PP
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.
.PP
See also parentWidget() and QToolTipGroup.
.SH "void QToolTip::hide ()\fC [static]\fR"
Hides any tip that is currently being shown.
.PP
Normally, there is no need to call this function; QToolTip takes care of showing and hiding the tips as the user moves the mouse.
This pure virtual function is half of the most versatile interface QToolTip offers.
.PP
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 \fIp\fR 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.
.PP
\fIp\fR is given in that widget's local coordinates. Most maybeTip() implementations will be of the form:
.PP
.nf
.br
if ( <something> ) {
.br
tip( <something>, <something> );
.br
}
.br
.fi
.PP
The first argument to tip() (a rectangle) must encompass \fIp\fR, i.e. the tip must apply to the current mouse position; otherwise QToolTip's operation is undefined.
.PP
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.
.PP
See also tip().
.PP
Examples:
.)l helpsystem/tooltip.cpp and tooltip/tooltip.cpp.
If \fIenable\fR is TRUE sets all tool tips to be enabled (shown when needed); if \fIenable\fR is FALSE sets all tool tips to be disabled (never shown).
.PP
By default, tool tips are enabled. Note that this function affects all tool tips in the entire application.
Immediately pops up a tip saying \fItext\fR and removes the tip once the cursor moves out of rectangle \fIrect\fR (which is given in the coordinate system of the widget this QToolTip relates to).
.PP
The tip will not reappear if the cursor moves back; your maybeTip() must reinstate it each time.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Immediately pops up a tip saying \fItext\fR and removes that tip once the cursor moves out of rectangle \fIrect\fR (which is given in the coordinate system of the widget this QToolTip relates to). \fIgroupText\fR is the text emitted from the group.
.PP
The tip will not reappear if the cursor moves back; your maybeTip() must reinstate it each time.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Immediately pops up a tip within the rectangle \fIgeometry\fR, saying \fItext\fR and removes the tip once the cursor moves out of rectangle \fIrect\fR. Both rectangles are given in the coordinate system of the widget this QToolTip relates to.
.PP
The tip will not reappear if the cursor moves back; your maybeTip() must reinstate it each time.
.PP
If the tip does not fit inside \fIgeometry\fR, the tip expands.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Immediately pops up a tip within the rectangle \fIgeometry\fR, saying \fItext\fR and removes the tip once the cursor moves out of rectangle \fIrect\fR. \fIgroupText\fR is the text emitted from the group. Both rectangles are given in the coordinate system of the widget this QToolTip relates to.
.PP
The tip will not reappear if the cursor moves back; your maybeTip() must reinstate it each time.
.PP
If the tip does not fit inside \fIgeometry\fR, the tip expands.