Qt 4.8
|
The QToolTip class provides tool tips (balloon help) for any widget. More...
#include <qtooltip.h>
Static Public Functions | |
static QFont | font () |
Returns the font used to render tooltips. More... | |
static void | hideText () |
Hides the tool tip. More... | |
static bool | isVisible () |
Returns true if this tooltip is currently shown. More... | |
static QPalette | palette () |
Returns the palette used to render tooltips. More... | |
static void | setFont (const QFont &) |
Sets the font used to render tooltips. More... | |
static void | setPalette (const QPalette &) |
Sets the palette used to render tooltips. More... | |
static void | showText (const QPoint &pos, const QString &text, QWidget *w=0) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This is analogous to calling QToolTip::showText(pos, text, w, QRect()) More... | |
static void | showText (const QPoint &pos, const QString &text, QWidget *w, const QRect &rect) |
Shows text as a tool tip, with the global position pos as the point of interest. More... | |
static QString | text () |
Returns the tooltip text, if a tooltip is visible, or an empty string if a tooltip is not visible. More... | |
Private Functions | |
QToolTip () | |
The QToolTip class provides tool tips (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 displayed in a tool tip is implicitly word-wrapped unless specified differently with
.
The simplest and most common way to set a widget's tool tip is by calling its QWidget::setToolTip() function.
It is also possible to show different tool tips for different regions of a widget, by using a QHelpEvent of type QEvent::ToolTip. Intercept the help event in your widget's QWidget::event() function and call QToolTip::showText() with the text you want to display. The Tooltips example illustrates this technique.
If you are calling QToolTip::hideText(), or QToolTip::showText() with an empty string, as a result of a QEvent::ToolTip-event you should also call QEvent::ignore() on the event, to signal that you don't want to start any tooltip specific modes.
Note that, if you want to show tooltips in an item view, the model/view architecture provides functionality to set an item's tool tip; e.g., the QTableWidgetItem::setToolTip() function. However, if you want to provide custom tool tips in an item view, you must intercept the help event in the QAbstractItemView::viewportEvent() function and handle it yourself.
The default tool tip color and font can be customized with setPalette() and setFont(). When a tooltip is currently on display, isVisible() returns true and text() the currently visible text.
Definition at line 55 of file qtooltip.h.
|
private |
|
static |
Returns the font used to render tooltips.
Definition at line 570 of file qtooltip.cpp.
|
inlinestatic |
Hides the tool tip.
This is the same as calling showText() with an empty string.
Definition at line 61 of file qtooltip.h.
Referenced by QMDIControl::event(), and QGraphicsScenePrivate::leaveScene().
|
static |
Returns true if this tooltip is currently shown.
Definition at line 527 of file qtooltip.cpp.
|
static |
Returns the palette used to render tooltips.
Definition at line 557 of file qtooltip.cpp.
Referenced by QRenderRule::QRenderRule(), and QTipLabel::QTipLabel().
|
static |
Sets the font used to render tooltips.
Definition at line 601 of file qtooltip.cpp.
|
static |
Sets the palette used to render tooltips.
Definition at line 586 of file qtooltip.cpp.
Referenced by qt_set_windows_color_resources().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This is analogous to calling QToolTip::showText(pos, text, w, QRect())
Definition at line 497 of file qtooltip.cpp.
Referenced by QMDIControl::event(), QTabBar::event(), QWidget::event(), QScriptToolTipJob::handleResponse(), QAbstractItemDelegate::helpEvent(), QGraphicsScene::helpEvent(), QTextControlPrivate::showToolTip(), showToolTip(), and QHeaderView::viewportEvent().
|
static |
Shows text as a tool tip, with the global position pos as the point of interest.
The tool tip will be shown with a platform specific offset from this point of interest.
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.
Definition at line 443 of file qtooltip.cpp.
|
static |
Returns the tooltip text, if a tooltip is visible, or an empty string if a tooltip is not visible.
Definition at line 541 of file qtooltip.cpp.